Description
Lets take an example to illustrate the issue
This portion of the schema
with:
type: object
title: HTTPArguments
description: The HTTP call arguments.
properties:
method:
type: string
title: WithHTTPMethod
description: The HTTP method of the HTTP request to perform.
endpoint:
title: WithHTTPEndpoint
description: The HTTP endpoint to send the request to.
oneOf:
- $ref: '#/$defs/endpoint'
- $ref: '#/$defs/runtimeExpression'
- title: LiteralEndpoint
type: string
format: uri-template
is translated to
public class HTTPArguments implements Serializable
{
@JsonProperty("endpoint")
@JsonPropertyDescription("The HTTP endpoint to send the request to.")
@NotNull
private Object endpoint;
}
Alhought an Endpoint class is generated, when using this definition
do:
- getPet:
call: http
with:
method: get
endpoint:
uri: https://petstore.swagger.io/v2/pet/{petId}
output: response
A LinkedHasHMap rather than an Endpoint (a class that is generated, but never used) instance is assigned to endpooint filed, which forces the user of the SDK to write (even incorreclty assuming the uri field is used, which is not necessarily true) this ugly code
String uri = ((Map) httpArgs.getEndpoint()).get("uri").toString();
A custom deserializer wont be enough, because although it will allow to use this somehow "better" form
((Endpoint) httpArgs.getEndpoint()).getUri()
still have obvious problems: Besides being prompt to ClassCastExcpetion, it forces the user to somehow know that endpoint
field might hold an Endpoint
object
Therefore, we need to make a breaking backward compatibility change (which is one of the advantages of being in alpha state ;), and rather than an Object field for endpoint, generate a new Union class with getters for all possible value types, as current happen when all possible types are generated classes, for example Call