swagger-api / swagger-api/swagger-codegen
Swagger CodeGen Error- More than one inline schema specified in allOf:. Only the first one is recognized. All others are ignored
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I have a file provMnS.yaml and it is referring to some other file nrNrm.yaml where SubNetwork-Single model definition is present. But due to allOf in the definition SubNetwork-Single model is not getting generated. If I change allOf to oneOf then the model is generated. I have to use allOf only as per the specification yaml. Please help me to resolve it.
Yaml snippet:
SubNetwork-Single:
allOf:
- $ref: 'C:\Users\xxxx\Documents\Docs\Project\yyyy\tasks\2504\Latest16th-MnS-Rel-16-SA-91\MnS-Rel-16-SA-91\OpenAPI\genericNrm.yaml#/components/schemas/Top-Attr'
- type: object
properties:
attributes:
allOf:
- $ref: 'C:\Users\xxxx\Documents\Docs\Project\yyyy\tasks\2504\Latest16th-MnS-Rel-16-SA-91\MnS-Rel-16-SA-91\OpenAPI\genericNrm.yaml#/components/schemas/SubNetwork-Attr'
- $ref: 'C:\Users\xxxx\Documents\Docs\Project\yyyy\tasks\2504\Latest16th-MnS-Rel-16-SA-91\MnS-Rel-16-SA-91\OpenAPI\genericNrm.yaml#/components/schemas/SubNetwork-ncO'
- type: object
properties:
SubNetwork:
$ref: '#/components/schemas/SubNetwork-Multiple'
Error and Exception while running swagger-codegen-cli jar:
C:\Users\xxxx\Documents\Docs\SWs\open api generator>java -jar swagger-codegen-cli-3.0.29.jar generate -i C:/Users/xxxx/Documents/Docs/Project/yyyy/tasks/2504/Latest16th-MnS-Rel-16-SA-91/MnS-Rel-16-SA-91/OpenAPI/provMnS.yaml -l spring
23:18:22.457 [Thread-1] WARN i.s.c.v.g.DefaultCodegenConfig - String to be sanitized is null. Default to Object
23:18:22.470 [Thread-1] WARN i.s.c.v.g.DefaultCodegenConfig - More than one inline schema specified in allOf:. Only the first one is recognized. All others are ignored.
Exception in thread "Thread-1" java.lang.RuntimeException: Could not process model 'SubNetwork-Single'.Please make sure that your schema is correct!
at io.swagger.codegen.v3.DefaultGenerator.generateModels(DefaultGenerator.java:386)
at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:779)
at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:388)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.v3.generators.DefaultCodegenConfig.addProperties(DefaultCodegenConfig.java:1527)
version- swagger-codegen-cli-3.0.29.jar
Please help me to resolve it.
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 3.0.29 generation command and the SubNetwork-Single schema in provMnS.yaml, including its references to nrNrm.yaml. Trace model generation through DefaultGenerator.generateModels and DefaultCodegenConfig.addProperties, then verify that the model generates without the allOf warning or NullPointerException while retaining the specified allOf structure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100