-
Notifications
You must be signed in to change notification settings - Fork 226
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
Fix synthetic schema naming #695
Fix synthetic schema naming #695
Conversation
String pointer = context.putSynthesizedSchema(synthesizedName, schema); | ||
MediaTypeObject mediaTypeObject = MediaTypeObject.builder() | ||
.schema(Schema.builder().ref(pointer).build()) | ||
.build(); | ||
|
||
responseBuilder.putContent(mediaType, mediaTypeObject); | ||
} | ||
|
||
private String stripNonAlphaNumericCharsIfNecessary(Context<T> context, String name) { | ||
return context.getConfig().getAlphanumericOnlyRefs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna want to at least log an info / warning here saying what's happening
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added logging in cd8a781.
InputStream openApiStream = getClass().getResourceAsStream(openApiModel); | ||
|
||
if (openApiStream == null) { | ||
LOGGER.warning("OpenAPI model not found for test case: " + openApiModel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should fail the test here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated all the cases to fail in 5333705.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to merge when the log message is updated
: name; | ||
String alphanumericOnly = NON_ALPHA_NUMERIC.matcher(name).replaceAll(""); | ||
if (context.getConfig().getAlphanumericOnlyRefs() && !alphanumericOnly.equals(name)) { | ||
LOGGER.info("Removing non-alphanumeric characters from " + name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should say why you're doing that
Some vendors, including Amazon API Gateway, require that shape names are alphanumeric only.
This PR assures that the synthesized
ResponseContent
andRequestContent
shapes have alphanumeric names when thealphanumericOnlyRefs
configuration setting has been set totrue
, as withsmithy-aws-apigateway-openapi
. The descriptions on schemas are updated to match when non-alphanumeric characters have been removed.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.