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

[BUG][Python] allOff not supported when used in array, in object #1657

Closed
tomghyselinck opened this issue Dec 10, 2018 · 5 comments
Closed
Labels
Client: Python Inline Schema Handling Schema contains a complex schema in items/additionalProperties/allOf/oneOf/anyOf Issue: Bug

Comments

@tomghyselinck
Copy link
Contributor

tomghyselinck commented Dec 10, 2018

Description

We have an object definition (i.e. SomeRemoteObject) which contains a schema which maps a few "names" (e.g. some_object_list) to an array of items.
Each of these items is a composition (using allOf) of an ID (i.e. RemoteId) with data (i.e. SomeObjectData).

Note that it does work when we wrap RemoteId and SomeObjectData in SomeObjectDataWithReference first (see allOf-python-issue.working.yaml).

Please note that I stripped down the example yaml file, to a bare minimum. For example the SomeRemoteObject only contains one "name" being mapped to an array of items.

When generating Python client code we get the following warning:

Please note that we also see these warning when generating for example html documentation or code for other target languages.

[main] INFO  o.o.codegen.DefaultCodegen - Composed schema not yet supported: class ComposedSchema {
    class Schema {
        title: null
        multipleOf: null
        maximum: null
        exclusiveMaximum: null
        minimum: null
        exclusiveMinimum: null
        maxLength: null
        minLength: null
        pattern: null
        maxItems: null
        minItems: null
        uniqueItems: null
        maxProperties: null
        minProperties: null
        required: null
        type: null
        not: null
        properties: null
        additionalProperties: null
        description: null
        format: null
        $ref: null
        nullable: null
        readOnly: null
        writeOnly: null
        example: null
        externalDocs: null
        deprecated: null
        discriminator: null
        xml: null
    }
    allOf: [class Schema {
        title: null
        multipleOf: null
        maximum: null
        exclusiveMaximum: null
        minimum: null
        exclusiveMinimum: null
        maxLength: null
        minLength: null
        pattern: null
        maxItems: null
        minItems: null
        uniqueItems: null
        maxProperties: null
        minProperties: null
        required: null
        type: null
        not: null
        properties: null
        additionalProperties: null
        description: null
        format: null
        $ref: #/components/schemas/RemoteId
        nullable: null
        readOnly: null
        writeOnly: null
        example: null
        externalDocs: null
        deprecated: null
        discriminator: null
        xml: null
    }, class Schema {
        title: null
        multipleOf: null
        maximum: null
        exclusiveMaximum: null
        minimum: null
        exclusiveMinimum: null
        maxLength: null
        minLength: null
        pattern: null
        maxItems: null
        minItems: null
        uniqueItems: null
        maxProperties: null
        minProperties: null
        required: null
        type: null
        not: null
        properties: null
        additionalProperties: null
        description: null
        format: null
        $ref: #/components/schemas/SomeObjectData
        nullable: null
        readOnly: null
        writeOnly: null
        example: null
        externalDocs: null
        deprecated: null
        discriminator: null
        xml: null
    }]
    anyOf: null
    oneOf: null
}
openapi-generator version

I used OpenAPI generator CLI version 4.0.0-SNAPSHOT:
https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/openapi-generator-cli-4.0.0-20181210.103357-85.jar

OpenAPI declaration file content or url

See allOf-python-issue.yaml in the attached zip-file:
allOf-python-issue.zip

Command line used for generation
java -jar openapi-generator-cli-4.x.jar generate -i ./allOf-python-issue.yaml -g python -o ./allOf-python-issue/client/python
Steps to reproduce

See also allOf-python-issue.sh in the attached zip-file.

wget \
        'https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/openapi-generator-cli-4.0.0-20181210.103357-85.jar' \
        -O 'openapi-generator-cli-4.x.jar'
java -jar openapi-generator-cli-4.x.jar generate -i ./allOf-python-issue.yaml -g python -o ./allOf-python-issue/client/python

allOf-python-issue.sh will also generate the HTML documentation (which poses the same issue) and the working version allOf-python-issue.working.yaml.

Related issues/PRs
Suggest a fix

I would like to make a suggestion, but I did not dive very deep into the code yet.

@ericraymond
Copy link

FYI, getting similar issue when running against my file with latest 4.0 snapshot. If it would be helpful I can try to extract a test case that strips out the rest of the file.

Relevant part seems to be:

    ValueBox:
      allOf:
        - $ref: '#/components/schemas/TextBox'
        - $ref: '#/components/schemas/Value'
    ValueBoxes:
      type: array
      items:
        $ref: '#/components/schemas/ValueBox'
Exception in thread "main" java.lang.RuntimeException: Could not process model 'ValueBox'.Please make sure that your schema is correct!
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:457)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:891)
	at org.openapitools.codegen.cmd.Generate.run(Generate.java:354)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:62)
Caused by: java.lang.RuntimeException: Please report the issue: Cannot process Composed Schema in addProperties: class ComposedSchema {
    class Schema {
        title: null
        multipleOf: null
        maximum: null
        exclusiveMaximum: null
        minimum: null
        exclusiveMinimum: null
        maxLength: null
        minLength: null
        pattern: null
        maxItems: null
        minItems: null
        uniqueItems: null
        maxProperties: null
        minProperties: null
        required: null
        type: null
        not: null
        properties: null
        additionalProperties: null
        description: null
        format: null
        $ref: null
        nullable: null
        readOnly: null
        writeOnly: null
        example: null
        externalDocs: null
        deprecated: null
        discriminator: null
        xml: null
    }
    allOf: [class Schema {
        title: null
        multipleOf: null
        maximum: null
        exclusiveMaximum: null
        minimum: null
        exclusiveMinimum: null
        maxLength: null
        minLength: null
        pattern: null
        maxItems: null
        minItems: null
        uniqueItems: null
        maxProperties: null
        minProperties: null
        required: null
        type: null
        not: null
        properties: null
        additionalProperties: null
        description: null
        format: null
        $ref: #/components/schemas/Segment
        nullable: null
        readOnly: null
        writeOnly: null
        example: null
        externalDocs: null
        deprecated: null
        discriminator: null
        xml: null
    }, class Schema {
        title: null
        multipleOf: null
        maximum: null
        exclusiveMaximum: null
        minimum: null
        exclusiveMinimum: null
        maxLength: null
        minLength: null
        pattern: null
        maxItems: null
        minItems: null
        uniqueItems: null
        maxProperties: null
        minProperties: null
        required: null
        type: null
        not: null
        properties: null
        additionalProperties: null
        description: null
        format: null
        $ref: #/components/schemas/Text
        nullable: null
        readOnly: null
        writeOnly: null
        example: null
        externalDocs: null
        deprecated: null
        discriminator: null
        xml: null
    }]
    anyOf: null
    oneOf: null
}
	at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:1866)
	at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1732)
	at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1133)
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:452)
	... 3 more

@tomghyselinck
Copy link
Contributor Author

@ericraymond I think what you see might be related to some buggy (or lack of) multi-level inheritance support.

See also #1662 (comment)

@tomghyselinck
Copy link
Contributor Author

The issue from @ericraymond may also be related to #583?

@tomghyselinck
Copy link
Contributor Author

@ericraymond : @wing328 is working on a fix in #1842

@spacether
Copy link
Contributor

spacether commented Sep 16, 2022

allOf is now working in the python and python-experimental generators

If you need the allOf to work in any schema and at any depth of inlining, please use the python-experimental generator.

All of those tests are passing in CI in node4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client: Python Inline Schema Handling Schema contains a complex schema in items/additionalProperties/allOf/oneOf/anyOf Issue: Bug
Projects
None yet
Development

No branches or pull requests

3 participants