oneOf with discriminator on path
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- openapi, python
- Domain
- api, backend-api-design
Research direction
Start with the minimal OpenAPI example in the issue and review how discriminator validation is handled for request bodies and path parameters. Check the project's validation entry points and tests for oneOf and discriminator behavior; done should clarify or implement the expected relationship between the path item_type and the selected schema.
Written by the indexing model from the issue text.
Description
As all different types of request bodies should be processed by the same function, I was hoping to do something the following minimal example:
/api/{item_type}:
post:
parameters:
- in: path
name: item_type
required: true
schema:
type: string
requestBody:
$ref: '#/components/requestBodies/object'
required: true
responses:
'201':
description: Item created
components:
requestBodies:
object:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Movie'
- $ref: '#/components/schemas/Program'
discriminator:
propertyName: item_type
schemas:
Movie:
type: object
Program:
type: object
Essentially, I want one function, to parse all item_types, but still ensure validation based on item_type in the path. However, I can create a Movie with the properties of Program.
Is this not the intended use? Or is there no discriminator validation on parameters specified in the path?
Thanks in advance.
- Dominant language
- Python
- Stars
- 409
- Forks
- 73
- PR merge metrics
- No merged PRs in 30d
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.
More from python-openapi/openapi-spec-validator
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
python-openapi/openapi-spec-validator#400 · 1 comment ·
-
kind/bug/confirmed
Difficulty 5/5 Over a week Newbie friendliness 25/100
python-openapi/openapi-spec-validator#373 · 1 comment ·
All issues in python-openapi/openapi-spec-validator
Similar issues
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DiamondLightSource/dodal#2211 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openml/openml-python#1749 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sipyourdrink-ltd/bernstein#6191 ·