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

[Java] Generate model for component with allOf has not attributes #1602

Closed
ravthiru opened this issue Dec 4, 2018 · 7 comments
Closed

[Java] Generate model for component with allOf has not attributes #1602

ravthiru opened this issue Dec 4, 2018 · 7 comments

Comments

@ravthiru
Copy link

ravthiru commented Dec 4, 2018

Description
openapi-generator version

3.3.4

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
@wing328
Copy link
Member

wing328 commented Dec 4, 2018

@ravthiru can you please test #1360 to see if it fixes the issues for you?

@ravthiru
Copy link
Author

ravthiru commented Dec 4, 2018

@wing328 which snapshot version i should use for testing

@wing328
Copy link
Member

wing328 commented Dec 4, 2018

@ravthiru you will need to build the JAR from the branch locally as the PR has not yet been merged into master.

@ravthiru
Copy link
Author

ravthiru commented Dec 5, 2018

No the said branch has not fixed the issue, for below spec Pet model class should have id, name and tag attributes, but with generated Pet Model class only extends Address

Pet:
      allOf:
        - $ref: "#/components/schemas/address"
        - type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
    address:
      type: object
      properties:
        location:
          type: string
        city:
          type: string

@ravthiru
Copy link
Author

ravthiru commented Dec 5, 2018

I used the branch oas3-spec-support1

@jmini
Copy link
Member

jmini commented Dec 5, 2018

@ravthiru: I did not look in detail at the change made in the PR, but I think that the correct way of expressing what you want is:

components:
  schemas:
    Pet:
        allOf:
          - $ref: "#/components/schemas/address"
          - type: object
            required:
              - id
              - name
            properties:
              id:
                type: integer
                format: int64
              name:
                type: string
              tag:
                type: string
    address:
        type: object
        properties:
          location:
            type: string
          city:
            type: string

=> Please notice the indentation difference.

And as far as I know this is already working with version 3.x.x. It produces a child class.

@wing328 : swagger-editor https://editor.swagger.io/ seems to support this as well:

components:
  schemas:
    Pet:
        allOf:
          - $ref: "#/components/schemas/address"
        type: object
        required:
          - id
          - name
        properties:
          id:
            type: integer
            format: int64
          name:
            type: string
          tag:
            type: string
    address:
        type: object
        properties:
          location:
            type: string
          city:
            type: string

I am not sure if this is correct or not from an OpenAPI Spec perspective or not and I also did not look at how the Swagger-Parser is parsing this.

@ravthiru
Copy link
Author

ravthiru commented Dec 6, 2018

Thanks it was because of indentation issue , it is working now

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

3 participants