Skip to content

Wrong Schema when multiple anyOf/oneOf are inside allOf #5144

@alexby

Description

@alexby

Q&A

  • OS: Ubuntu
  • Browser: chrome
  • Version: online
  • Method of installation: online
  • Swagger-Editor version: online
  • Swagger/OpenAPI version: 3.1.0

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  version: 0.0.42
  title: some title
paths:
  /v1/user:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - anyOf:
                    - type: object
                      properties:
                        firstA:
                          type: string
                    - type: object
                      properties:
                        firstB:
                          type: string
                  - anyOf:
                    - type: object
                      properties:
                        secondA:
                          type: string
                    - type: object
                      properties:
                        secondB:
                          type: string

Describe the bug you're encountering

Having multiple anyOf (or oneOf) inside the allOf will make the both conditions to be joined in a single anyOf (oneOf). In other words the condition (firstA OR firstB) AND (secondA OR secondB) is rendered like firstA OR firstB OR secondA OR secondB.

Expected behavior

image

Actual behavior

image

Additional context or thoughts

Having different conditions (oneOf & anyOf) under the same allOf will be resulted in a correct Schema.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions