Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Code Generation issue in 3.0.9 with OpenAPI 3.0 Version #9548

Closed
shameerkc opened this issue Jul 8, 2019 · 1 comment
Closed

Spring Code Generation issue in 3.0.9 with OpenAPI 3.0 Version #9548

shameerkc opened this issue Jul 8, 2019 · 1 comment

Comments

@shameerkc
Copy link

shameerkc commented Jul 8, 2019

Description

When I execute the code generation using version 3.0.8 is works just fine.

java -jar swagger-codegen-cli-3.0.8.jar generate -i TS29571_CommonData.yaml -l spring -o GENERATED_COMMON_08

However, when the same command is tried with latest version, it does not work.

java -jar swagger-codegen-cli-3.0.9.jar generate -i TS29571_CommonData.yaml -l spring -o GENERATED_COMMON_09

Corresponding logs can be seen below:

`
14:51:15.423 [Thread-1] WARN io.swagger.codegen.v3.generators.java.AbstractJavaCodegen - Double (reserved word) cannot be used as model name. Renamed to ModelDouble
Exception in thread "Thread-1" java.lang.RuntimeException: Could not process model 'PatchOperation'.Please make sure that your schema is correct!
at io.swagger.codegen.v3.DefaultGenerator.generateModels(DefaultGenerator.java:378)
at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:756)
at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:342)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.v3.generators.util.OpenAPIUtil.getSimpleRef(OpenAPIUtil.java:32)
at io.swagger.codegen.v3.generators.SchemaHandler.configureAnyOfModel(SchemaHandler.java:75)
at io.swagger.codegen.v3.generators.DefaultCodegenConfig.fromModel(DefaultCodegenConfig.java:1374)
at io.swagger.codegen.v3.generators.java.AbstractJavaCodegen.fromModel(AbstractJavaCodegen.java:895)
at io.swagger.codegen.v3.DefaultGenerator.processModels(DefaultGenerator.java:988)
at io.swagger.codegen.v3.DefaultGenerator.generateModels(DefaultGenerator.java:349)

`

Corresponding API Element

PatchOperation:
   anyOf:
     - type: string
       enum:
         - add
         - copy
         - move
         - remove
         - replace
         - test
     - type: string
Swagger-codegen version

3.0.9

Swagger declaration file content or url

https://github.com/jdegre/5GC_APIs

Common Data is giving the exception - Matching - Common Data

    PatchOperation:
      anyOf:
        - type: string
          enum:
            - add
            - copy
            - move
            - remove
            - replace
            - test
        - type: string
Command line used for generation

Below command works fine:

java -jar swagger-codegen-cli-3.0.8.jar generate -i TS29571_CommonData.yaml -l spring -o GENERATED_COMMON_08

Below line when tried with 3.0.9 breaks it:

java -jar swagger-codegen-cli-3.0.9.jar generate -i TS29571_CommonData.yaml -l spring -o GENERATED_COMMON_09
`


14:51:15.423 [Thread-1] WARN io.swagger.codegen.v3.generators.java.AbstractJavaCodegen - Double (reserved word) cannot be used as model name. Renamed to ModelDouble
Exception in thread "Thread-1" java.lang.RuntimeException: Could not process model 'PatchOperation'.Please make sure that your schema is correct!
at io.swagger.codegen.v3.DefaultGenerator.generateModels(DefaultGenerator.java:378)
at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:756)
at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:342)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.v3.generators.util.OpenAPIUtil.getSimpleRef(OpenAPIUtil.java:32)
at io.swagger.codegen.v3.generators.SchemaHandler.configureAnyOfModel(SchemaHandler.java:75)
at io.swagger.codegen.v3.generators.DefaultCodegenConfig.fromModel(DefaultCodegenConfig.java:1374)
at io.swagger.codegen.v3.generators.java.AbstractJavaCodegen.fromModel(AbstractJavaCodegen.java:895)
at io.swagger.codegen.v3.DefaultGenerator.processModels(DefaultGenerator.java:988)
at io.swagger.codegen.v3.DefaultGenerator.generateModels(DefaultGenerator.java:349)
`

Steps to reproduce

The corresponding JAR's hwere downloaded from Maven Central https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/

Related issues/PRs

None

Suggest a fix/enhancement

It looks specific to handling of the anyOf allOf kind of tags.

@shameerkc shameerkc changed the title Spring Code Generation issue in 3.0.9 Spring Code Generation issue in 3.0.9 with OpenAPI 3.0 Version Jul 8, 2019
frantuma added a commit to swagger-api/swagger-codegen-generators that referenced this issue Jul 10, 2019
frantuma added a commit to swagger-api/swagger-codegen-generators that referenced this issue Jul 10, 2019
@frantuma
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants