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

Wrap refs with defaults in an allOf #1887

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

srchase
Copy link
Contributor

@srchase srchase commented Jul 27, 2023

Fixes #1844.

According to both the 3.1.0 spec, and the 3.0.2 spec, additional fields on referenceObjects are ignored.

This PR adds a JsonSchema configuration option, disableDefaultValues. JsonSchemaShapeVisitor is updated to wrap any members with a @default trait applied which target a $ref with an allOf so that the default can be handled correctly by OpenAPI when this configuration option is enabled.

While JsonSchema's configuration will use this setting by default, it is disabled by default for API Gateway. API Gateway does not support default values anyways, so disabling this option will make $ref and top-level definitions consistent by not using defaults in either form.

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 July 27, 2023 23:17
@mtdowling
Copy link
Member

Can you test this to make sure it works with APIGW?

},
{
"default": "FOO"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is a better way to do member documentation traits too

@srchase
Copy link
Contributor Author

srchase commented Jul 28, 2023

Can you test this to make sure it works with APIGW?

Updated the issue description with API Gateway testing.

@srchase srchase force-pushed the defaults-on-refs branch 2 times, most recently from 73a5408 to 91450b7 Compare July 31, 2023 19:50
@srchase srchase force-pushed the defaults-on-refs branch from 91450b7 to 36f1754 Compare July 31, 2023 20:49
@srchase srchase merged commit ef15e6d into smithy-lang:main Jul 31, 2023
@srchase srchase deleted the defaults-on-refs branch July 31, 2023 21:34
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.

OpenAPI plugin generates incorrect schema for enums with default values
2 participants