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

Generated examples don't include all attributes when an allOf also contains an anyOf/oneOf #7040

Closed
gwerbin opened this issue Mar 6, 2021 · 2 comments · Fixed by #7041
Closed

Comments

@gwerbin
Copy link

gwerbin commented Mar 6, 2021

Q&A (please complete the following information)

  • OS: macOS
  • Browser: Chrome
  • Version: 88
  • Method of installation: N/A
  • Swagger-UI version: Using https://editor.swagger.io
  • Swagger/OpenAPI version: OpenAPI 3.0.3

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.3
info:
  title: 'Things n stuff'
  version: 1.0.0

paths:
  '/data':
    get:
      responses:
        '200':
          description: 'The things you asked for.'
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PageInfo'
                  - type: object
                    required:
                      - items
                    properties:
                      items:
                        type: array
                        items:
                          allOf:
                            - anyOf:
                              - $ref: '#/components/schemas/Thing1'
                              - $ref: '#/components/schemas/Thing2'
                            - type: object
                              required:
                                - isImportant
                              properties:
                                isImportant:
                                  type: boolean

components:
  schemas:
    BaseThing:
      type: object
      required:
        - color
      properties:
        color:
          type: string

    Thing1:
      allOf:
        - $ref: '#/components/schemas/BaseThing'
        - type: object
          properties:
            color:
              type: string
              enum:
                - blue
                - red

    Thing2:
      allOf:
        - $ref: '#/components/schemas/BaseThing'
        - type: object
          properties:
            color:
              type: string
              enum:
                - green
                - yellow

    PageInfo:
      type: object
      properties:
        pageNumber:
          type: number
          minimum: 0
        totalPages:
          type: number
          minimum: 0

Describe the bug you're encountering

The isImportant property is not added to the generated example. See the "screenshots" section.

The schema itself appears to be correct in the generated UI.

To reproduce...

Copy and paste the schema above into https://editor.swagger.io/.

Expected behavior

I expected the generated example in the screenshot to include isImportant.

Screenshots

Additional context or thoughts

Thank you for the useful tool!

@mathis-m
Copy link
Contributor

mathis-m commented Mar 6, 2021

@gwerbin Thank you for reporting this. Perfect minimal reproduction yaml, I could find the issue instantly, very appreciated. Fix provided with #7041.

@gwerbin
Copy link
Author

gwerbin commented Mar 6, 2021

I actually forgot to upload the screenshot of the problematic generated example, but glad you were able to find it easily nonetheless!

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

Successfully merging a pull request may close this issue.

2 participants