A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.
Apache License 2.0
23
stars
7
forks
source link
Reslang generated swagger does not support Polymorphism properly #200
OPI API specs rely on several polymorphic objects, the OutputMetadata being one of them. However, the clients OpenAPI generates from the reslang-generated-swagger are not properly handling polymorphism:
the server returns the appropriate response, but all the information is lost when the client that receives the response deserializes the json into the actual polymorphic object. As a result, the outputMetadata response is an empty object.
Our assumption is that this problem is happening because Reslang generates non-polymorphic-compatible Swagger specs. Until Reslang is modified to generate proper Swagger specs, if consumers want to bump their OpenAPI clients so that they get the latest production features, we need to manually fix the specs (by copying changes made by this PR), and merge the PR to publish a new set of clients with valid polymorphism.
Note: we assumed that the above PR changes are correct based on:
and the fact that not adding the type property to the classes extending the base class (here OutputMetadataBatchOutputMetadata "extending" OutputMetadata), or not specifying it as a required property, yields to this runtime error during code generation
java.lang.RuntimeException: 'OutputMetadata' defines discriminator 'type', but the referenced schema 'OutputMetadataBatchOutputMetadata' is incorrect. type is missing from the schema, define it as required and type string
To Reproduce
generate dist-api swagger specs from our reslang file
build ruby api client from the generated swagger using OpenAPI codegen tool
call GET '/v1/distribution-requests/{id} for a DSJ through a curl, and notice the presence of an output metadata
call the same method using the generated ruby client, response = DistApiClient::DistributionRequestApi.get(dsjID) and response.output_metadata would be nil
Expected Behavior
We'd want the generated ruby client to be able to parse the polymorphic object from the response
OPI API specs rely on several polymorphic objects, the OutputMetadata being one of them. However, the clients OpenAPI generates from the reslang-generated-swagger are not properly handling polymorphism:
Our assumption is that this problem is happening because Reslang generates non-polymorphic-compatible Swagger specs. Until Reslang is modified to generate proper Swagger specs, if consumers want to bump their OpenAPI clients so that they get the latest production features, we need to manually fix the specs (by copying changes made by this PR), and merge the PR to publish a new set of clients with valid polymorphism.
Note: we assumed that the above PR changes are correct based on:
type
property to the classes extending the base class (hereOutputMetadataBatchOutputMetadata
"extending"OutputMetadata
), or not specifying it as a required property, yields to this runtime error during code generationTo Reproduce
'/v1/distribution-requests/{id}
for a DSJ through a curl, and notice the presence of an output metadataresponse = DistApiClient::DistributionRequestApi.get(dsjID)
andresponse.output_metadata
would be nilExpected Behavior
We'd want the generated ruby client to be able to parse the polymorphic object from the response
Reslang Version
Master/Latest