Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Open
@baywet

Description

@baywet
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.