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

[PYTHON] Bug: allOf tag not supported in inline schema #3225

Open
robert-lawrence opened this issue Jun 27, 2016 · 3 comments
Open

[PYTHON] Bug: allOf tag not supported in inline schema #3225

robert-lawrence opened this issue Jun 27, 2016 · 3 comments

Comments

@robert-lawrence
Copy link

robert-lawrence commented Jun 27, 2016

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.

@wing328
Copy link
Contributor

wing328 commented Jun 28, 2016

@rob2001 is the issue similar to #2924 ?

@robert-lawrence
Copy link
Author

@wing328 I think this is a slightly different, but related issue. Regardless of what order I put the allOf schemas in, it will always fail unless I use a reference to point to the allOf schema itself. I just tested this by switching the model order in my swaggerFail gist. Both of these issues might be caused by the same problem though.

@wing328
Copy link
Contributor

wing328 commented Jun 28, 2016

@rob2001 thanks for performing more tests to confirm the issue. Please define the model instead of using inline schema as a workaround for the time being.

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

No branches or pull requests

2 participants