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

Discriminator property in component disappears from component when mapping is used under discriminator #8336

Open
Numerlor opened this issue Jan 6, 2023 · 2 comments · May be fixed by #10222

Comments

@Numerlor
Copy link

Numerlor commented Jan 6, 2023

When I have the discriminator property explicitly listed on the components that are under a oneOf, it disappears when mapping is used under discriminator.

For example with the following document, the example is

{
  "prop2": "string"
}

but with mapping removed it changes into

{
  "prop2": "string",
  "type": "string"
}
OpenAPI document
openapi: 3.0.3
info:
  title: ''
  version: 0.0.0
paths:
  /test/:
    post:
      operationId: test_create
      tags:
        - events
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TestPolymorphic'
      responses:
        '200':
          description: ''
components:
  schemas:
    Test1:
      type: object
      properties:
        prop1:
          type: string
        type:
          type: string
      required:
        - prop1
        - type
        
    Test2:
      type: object
      properties:
        prop2:
          type: string
        type:
          type: string
      required:
        - prop2
        - type
        

    TestPolymorphic:
      oneOf:
        - $ref: '#/components/schemas/Test2'
        - $ref: '#/components/schemas/Test1'
      discriminator:
        propertyName: type
        mapping:
          Test2: '#/components/schemas/Test2'
          Test1: '#/components/schemas/Test1'
@Laikos38
Copy link

Hi! Did you find a solution to this?

@Numerlor
Copy link
Author

Hi! Did you find a solution to this?

Just went with Redoc

@Brads3290 Brads3290 linked a pull request Nov 22, 2024 that will close this issue
17 tasks
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