OpenAPITools / OpenAPITools/openapi-generator
[BUG][Spring] generated api interface doesn't have @RequestParam annotation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
I updated openapi-generator from 4.0.1 to 4.0.2. Then, I found generated api interface from same spec is different between 4.0.1 and 4.0.2.
For some reason, @RequestParam is not generated for api parameters. Here is an example.
- 4.0.1
@ApiParam(value = "", allowableValues = "json, csv, tsv", defaultValue = "json")
@Valid
@RequestParam(value = "format", required = false, defaultValue = "json")
Format format
- 4.0.2
@ApiParam(value = "", allowableValues = "json, csv, tsv", defaultValue = "json")
@Valid
Format format
openapi-generator version
4.0.2
OpenAPI declaration file content or url
openapi: 3.0.2
info:
title: info
description: info
version: 0.1.0
paths:
/example/api:
get:
summary: summary
description: description
parameters:
- $ref: '#/components/parameters/requiredQueryParam'
- $ref: '#/components/parameters/formatParam'
responses:
200:
description: response
content:
application/json:
schema:
type: string
components:
parameters:
requiredQueryParam:
description: set query
in: query
name: query
required: true
schema:
type: string
formatParam:
description: set format
in: query
name: format
required: false
schema:
$ref: '#/components/schemas/format'
schemas:
format:
default: json
description: response format
enum:
- json
- csv
type: string
Command line used for generation
$ mvn clean package
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ./simple-example-spec/openapi.spec -g spring -o output
Steps to reproduce
Generate api code for spring with 4.0.1 and 4.0.2. Then compare the api parameters of api interface.
Related issues/PRs
I couldn't find any similar issues.
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Spring generator entry point used by modules/openapi-generator-cli and reproduce the issue with simple-example-spec/openapi.spec using the provided Maven and Java commands. Compare generated API parameters for versions 4.0.1 and 4.0.2; done means query parameters again include the expected @RequestParam annotations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100