Skip to content

OAS 3.1: Support for const keyword #129

Closed
@CameronMackenzie99

Description

@CameronMackenzie99

OAS 3.1 introduced the const keyword (see discussion), syntactically equivalent to a single value enum, for example:

{
    "components": {
        "schemas": {
            "BingData": {
                "additionalProperties": false,
                "properties": {
                    "bing": {
                        "const": "Anything You Need",
                        "title": "Bing"
                    }
                },
                "required": [
                    "bing"
                ],
                "title": "BingData",
                "type": "object"
            },
            "DingData": {
                "additionalProperties": false,
                "properties": {
                    "anything_you_need": {
                        "const": "Anything You Need",
                        "title": "Anything You Need"
                    }
                },
                "required": [
                    "anything_you_need"
                ],
                "title": "DingData",
                "type": "object"
            }
        },
        "info": {
            "title": "Events",
            "version": "0.1.0"
        },
        "openapi": "3.1.0"
    }
}

Supporting this in the library will be really useful for consumers to be able to account for this keyword when parsing schemas.

I'm not entirely sure how this would be typed as I can see that the enum keyword is currently typed as any[] here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions