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

Add intEnum support for json-schema #1898

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

srchase
Copy link
Contributor

@srchase srchase commented Aug 1, 2023

This PR adds support for intEnums when converting to json-schema and OpenAPI and closes: #1667. This feature is enabled by default, but can be disabled by setting the disableIntEnums configuration property to true.

Currently, an intEnum is only represented as a "number".

The following Smithy model:

structure Foo {
    bar: TestIntEnum
}

intEnum TestIntEnum {
    FOO = 1
    BAR = 2
}

Is converted as:

{
    "definitions": {
        "Foo": {
            "type": "object",
            "properties": {
                "bar": {
                    "type": "number"
                }
            }
        }
    }
}

This PR adds the enum property to the output, and updates the ref strategy so that intEnums use a $ref the same way as enum shapes.

{
    "definitions": {
        "Foo": {
            "type": "object",
            "properties": {
                "bar": {
                    "$ref": "#/definitions/TestIntEnum"
                }
            }
        },
        "TestIntEnum": {
            "type": "number",
            "enum": [
                1,
                2
            ]
        }
    }
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@srchase srchase requested a review from a team as a code owner August 1, 2023 23:08
@srchase srchase changed the title Add intEnum support json-schema Add intEnum support for json-schema Aug 1, 2023
@srchase srchase force-pushed the json-schema-int-enum branch from 6ebfde1 to e48de86 Compare August 2, 2023 16:05
@srchase srchase force-pushed the json-schema-int-enum branch from e48de86 to 9ac9d59 Compare August 2, 2023 16:07
@srchase srchase merged commit 6279f9d into smithy-lang:main Aug 2, 2023
@srchase srchase deleted the json-schema-int-enum branch August 2, 2023 16:33
syall pushed a commit to Xtansia/smithy that referenced this pull request Aug 11, 2023
alextwoods pushed a commit to alextwoods/smithy that referenced this pull request Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement OpenAPI support for intEnum
3 participants