Issue with dropdown options for discriminated schema in request body
Open
@AlexVarchuk is already working on this.
Since Aug 8, 2023.
openapi
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.4k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 4
Description
When defining a schema for a request body that uses oneOf and a discriminator with a mapping, the dropdowns show the option for the base item as well, which is incorrect and should not be defined as an option.
Simplified Example:
openapi: 3.0.0
info:
title: test
version: 1.0.0
paths:
'/test/{testId}':
patch:
summary: Broken test
operationId: updateSchedule
parameters:
- $ref: '#/components/parameters/TestIdPath'
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/TestRequestBody'
responses:
'200':
$ref: '#/components/responses/TestModel'
components:
parameters:
TestIdPath:
in: path
required: true
name: testId
schema:
type: integer
schemas:
TestRequestBody:
allOf:
- $ref: '#/components/schemas/TestModel'
- description: Additional description
BaseTestModel:
type: object
properties:
baseProperty:
type: string
SubTestModel1:
allOf:
- $ref: '#/components/schemas/BaseTestModel'
- type: object
properties:
subProp1:
type: string
SubTestModel2:
allOf:
- $ref: '#/components/schemas/BaseTestModel'
- type: object
properties:
subProp2:
type: string
TestModel:
oneOf:
- $ref: '#/components/schemas/SubTestModel1'
- $ref: '#/components/schemas/SubTestModel2'
discriminator:
propertyName: baseProperty
mapping:
ONE: '#/components/schemas/SubTestModel1'
TWO: '#/components/schemas/SubTestModel2'
responses:
TestModel:
description: A test model
content:
application/vnd.yellowfin.api-v1+json:
schema:
$ref: '#/components/schemas/TestModel'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.