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

[Schema Inaccuracy] Consider using discriminator properties for union types #2974

Open
baywet opened this issue Sep 8, 2023 · 0 comments
Open

Comments

@baywet
Copy link

baywet commented Sep 8, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants