-
Notifications
You must be signed in to change notification settings - Fork 10
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 for discriminated union transform #176
Conversation
val componentSchemas: Map[String, Schema] = openapi | ||
val componentSchemas: Map[ShapeId, Schema] = openapi |
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.
Change to using full ShapeId instead of just shape name
@@ -130,6 +137,7 @@ class DiscriminatedUnionMemberComponents() extends OpenApiMapper { | |||
.asJava | |||
) | |||
schemaBuilder | |||
.removeExtension(DiscriminatedUnionShapeId.SHAPE_ID_KEY) |
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.
Remove the extension so it is not included in the final OpenAPI file
|
||
import software.amazon.smithy.model.node.Node | ||
|
||
class DiscriminatedUnionShapeId() extends JsonSchemaMapper { |
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.
A JsonSchemaMapper has to be used to get access to the full ShapeId, OpenAPI mappers do not have this information available (as far as I can tell).
This fixes an issue with there being two shapes from different namespaces with the same name where one of them is a discriminated union. The discriminated union transformation added in #173 did not use a full ShapeId for determining which shape is which, but rather only a name. There is no direct way to handle this, thus I used the OpenAPI extensions to carry the ShapeId and used that. See the files for more commentary about this.