swagger-api / swagger-api/swagger-codegen
[PYTHON] Bug: allOf tag not supported in inline schema
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
While working on a project, I discovered that I was unable to put 'allOf':[] schema defs in an inline definition. (by that I mean that I defined the schema inside the operation object).
For this particular project it is not desirable to put these definitions under the global definitions object, because it would lead to a very large definitions object that would be difficult to maintain.
Swagger-codegen version
Latest master as of June 25, 2016
Swagger declaration file
Here is a swagger file with an allOf definition in the definitions object. It generates successfully.
swagger.json
Here is a near identical script, but with the allOf definition in the inline schema. It does not validate successfully.
swaggerFail.json
Command line used for generation
Command line args & error message:
java -jar ~/workspace/git/vco/tools/api/swagger-codegen-cli.jar generate -i ~/git_issues/swaggerFail.json -l python -o ~/git_issues/python
[main] INFO io.swagger.parser.Swagger20Parser - reading from /home/vc/git_issues/swaggerFail.json
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /home/vc/git_issues/python/swagger_client/models/sub_model.py
[main] INFO io.swagger.codegen.DefaultGenerator - File exists. Skipped overwriting /home/vc/git_issues/python/test/test_sub_model.py
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /home/vc/git_issues/python/docs//SubModel.md
Exception in thread "main" java.lang.RuntimeException: Could not process operation:
Tag: default
Operation: no
Resource: post /thisDoesnt
Definitions: {sub_model=io.swagger.models.ModelImpl@80d280e4}
Exception: null
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:785)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:680)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:365)
at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.DefaultCodegen.isDataTypeBinary(DefaultCodegen.java:2250)
at io.swagger.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:2233)
at io.swagger.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:1835)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:733)
... 4 more
Steps to reproduce
Download the swaggerFail.json, and try to generate it with the command shown above.
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
Reproduce the failure with swaggerFail.json and the Java CLI command shown. Read DefaultGenerator.processOperation and the DefaultCodegen.fromOperation, fromParameter, and isDataTypeBinary stack frames, comparing them with the working swagger.json. Done when the inline allOf schema validates and Python generation completes without the reported exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100