swagger-api / swagger-api/swagger-codegen
[jaxrs-jersey] Codegen Producing Incorrect Output for YAML spec
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Hey all! I ran into a weird issue while trying to generate a jaxrs-jersey api. Please let me know if I'm doing something wrong or if it is a bug (and there is a work around). Thank you!
Here is my openapi spec in yaml: https://gist.github.com/andrewnottaviano/9f61f8c30a15a2dd21c65545f982fe9c
Here is the code it generated: https://gist.github.com/andrewnottaviano/e6d629d84728fc247d44fedf4226f3b6
Notice in the spec, the hyperlink field of "Thing" is of type is object, but the Java code that is output is of type List. Did I do something wrong or is this a bug?
Swagger-codegen version
Codegen version: "v3.0.19"
Codegen generators version: "v1.0.19"
It is worthy to note that I do not know what the online swagger editor uses (see replication steps below), but I first found this issue while using the versions above locally and was able to reproduce online.
Swagger declaration file content or url
See gist above
Command line used for generation
java -jar /Users/ao052270/Documents/Repos/DiscernAlerts/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate --lang jaxrs-jersey --input-spec ml-discern-rules.yaml --config config.json --output /Users/ao052270/Documents/Repos/DiscernAlerts/codeGen-output
Steps to reproduce
- Copy the yaml gist above and paste into https://editor.swagger.io/
- Click "Generate Server" and open the downloaded contents
- Open the file "Thing.java" and observe that the hyperlink field is of type "List" when type "Hyperlink" is expected.
Related issues/PRs
Suggest a fix/enhancement
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 swagger-codegen-cli generate command using the linked YAML gist and --lang jaxrs-jersey, then inspect the generated Thing.java. Compare the spec's object-typed hyperlink field with the generated List field. Done means generation produces Hyperlink for that field, verified against the provided reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100