Skip to content

Add intEnum support for json-schema#1898

Merged
srchase merged 1 commit intosmithy-lang:mainfrom
srchase:json-schema-int-enum
Aug 2, 2023
Merged

Add intEnum support for json-schema#1898
srchase merged 1 commit intosmithy-lang:mainfrom
srchase:json-schema-int-enum

Conversation

@srchase
Copy link
Copy Markdown
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