[Schema Inaccuracy] Consider using discriminator properties for union types
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- openapi
- Domain
- api, backend-api-design
Research direction
Start by reviewing the OpenAPI definition for GET /repos/{owner}/{repo}/contents/{path} and its content-directory, content-file, content-symlink, and content-submodule schemas. Determine whether an existing property can support the discriminator or whether a new one is needed, then verify that the union maps each response type and improves client deserialization.
Written by the indexing model from the issue text.
Description
Schema Inaccuracy
GET /repos/{owner}/{repo}/contents/{path}
Was recently updated from a single "object" schema to
application/json:
schema:
oneOf:
- "$ref": "#/components/schemas/content-directory"
- "$ref": "#/components/schemas/content-file"
- "$ref": "#/components/schemas/content-symlink"
- "$ref": "#/components/schemas/content-submodule"
While this is great to #650 's point as it more accurately describes the possible values, it also makes deserialization work on client applications much harder.
Expected
Consider adding something along the lines of
discriminator:
propertyName: newPropertyName
mapping:
content-file: "#/components/schemas/content-file"
content-submodule: "#/components/schemas/content-submodule"
content-symlink: "#/components/schemas/content-symlink"
(this would require introducing a new property if one with the mapping values doesn't already exist)
This way client applications can match the discrimator mapping value with the object type during deserialization.
Reproduction Steps
- Dominant language
- No language data
- Stars
- 1.6k
- Forks
- 342
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 51
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 github/rest-api-description
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
github/rest-api-description#7201 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
github/rest-api-description#7163 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/rest-api-description#7162 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/rest-api-description#7135 ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
github/rest-api-description#7111 · 1 comment ·
All issues in github/rest-api-description
Similar issues
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100