Closed emmanuelbernard closed 4 years ago
/cc @EricWittmann
Out of the box support for Uni
and Multi
would be great.
I'm wondering though if this could be made configurable (with the out of the box behavior being default configuration). From the top of my head, I can see another similar use cases where I might like to tweak the generated OpenAPI schema, but there might be many more:
No matter whether my API returns a Set<Fruit>
or a List<Fruit>
or a Collection<Fruit>
. To the consumer, the data is represented as a an array of fruit objects. I might want to map all of them to a single reference schema instead of generating different ones which in essence all define the same schema.
Yes: Multi would be an array, and Uni just the item type (Fruit)
/cc @phillip-kruger
Do we need to add support for these types explicitly in SmallRye OpenAPI?
For endpoints defined as:
@GET
@Path("/uni")
public Uni<String> uni() {
return Uni.createFrom().item("Hello from Uni");
}
@GET
@Path("/multi")
public Multi<String> multi() {
return Multi.createFrom().items("Hello", "from", "Multi");
}
@GET
@Path("/uniType")
public Uni<ComponentType> uniType() {
return Uni.createFrom().item(this::createComponent);
}
@GET
@Path("/multiType")
public Multi<ComponentType> multiType() {
return Multi.createFrom().items(createComponent(), createComponent());
}
I've got OpenAPI definition of:
"/test/multi": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
},
"/test/multiType": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ComponentType"
}
}
}
}
}
}
}
},
"/test/uni": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/test/uniType": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/ComponentType"
}
}
}
}
}
}
},
Is that correct?
Yes sounds like it is what should happen
When using
The schema is
Which is wrong. Uni and Multi should not be in the open api contract.
See https://stackoverflow.com/questions/61394139/openapi-spec-for-reactive-rest-service-using-quarkus
@cescoffier @kenfinnigan