swagger-api / swagger-api/swagger-codegen

[jaxrs-jersey] Codegen Producing Incorrect Output for YAML spec

Open
#10,232 0 comments 0 reactions 0 assignees View on GitHub

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
  1. Copy the yaml gist above and paste into https://editor.swagger.io/
  2. Click "Generate Server" and open the downloaded contents
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.