Skip to content

Revert enforce existence of composite applicator keyword adjacent to "discriminator" #3137 #3405

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

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

skryukov
Copy link
Contributor

This PR reverts changes from #3137

According to 3.1.x version of the spec the discriminator keyword MAY be added to a parent schema definition, example from the spec:

components:
  schemas:
    Pet:
      type: object
      required:
      - petType
      properties:
        petType:
          type: string
      discriminator:
        propertyName: petType
        mapping:
          dog: Dog
    Cat:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - type: object
        # all other properties specific to a `Cat`
        properties:
          name:
            type: string
    Dog:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - type: object
        # all other properties specific to a `Dog`
        properties:
          bark:
            type: string
    Lizard:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - type: object
        # all other properties specific to a `Lizard`
        properties:
          lovesRocks:
            type: boolean

See comment: #2618 (comment)

Copy link

@Malia1969 Malia1969 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

****
#2618
desciminador
_
_

"```****

@karenetheridge
Copy link
Member

karenetheridge commented Oct 27, 2023

+1. when I wrote that PR I clearly didn't think that example through enough :)

That example is buggy (I used it in a test today and got an infinite loop at #/components/schemas/Pet), but we can fix that separately, e.g. in Jason's #2618.

karenetheridge added a commit to karenetheridge/OpenAPI-Modern that referenced this pull request Oct 29, 2023
This restriction was also added and then removed from the dialect metaschema,
due to a misunderstanding of the spec.

see OAI/OpenAPI-Specification#3405

Also handle the ambiguity between named schema and uri-reference in mapping
entries.
@earth2marsh earth2marsh merged commit b02c548 into OAI:main Dec 7, 2023
@skryukov skryukov deleted the revert-discriminator-json-schema branch December 8, 2023 17:05
karenetheridge added a commit to karenetheridge/OpenAPI-Modern that referenced this pull request Feb 7, 2025
The requirement that oneOf, anyOf or allOf is required was added to the schema
in OAI/OpenAPI-Specification#3137 and then reverted
for v3.1.1 in OAI/OpenAPI-Specification#3405.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants