Quarkus openapi custom type mappings

38 views Asked by At

I want Quarkus to understand VAVR types in OpenAPI definitions.

=============== pom.xml ===============
<quarkus.platform.version>3.4.3</quarkus.platform.version>

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>

=============== application.properties ===============
quarkus.index-dependency.vavr.group-id=io.vavr
quarkus.index-dependency.vavr.artifact-id=vavr

=============== java code ===============
@Value
public class CustomerRequest {
    io.vavr.collection.List<CustomerEntry> customers;

    io.vavr.collection.Map<String, CustomerEntry> groupedCustomers;
}

=============== generated openapi.json ===============
"ListCustomerEntry": {
  "type": "array",
  "items": {
    "$ref": "#/components/schemas/CustomerEntry"
  }
},
"MapStringCustomerEntry": {
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "_1": {
                "type": "string"
            },
            "_2": {
                "$ref": "#/components/schemas/CustomerEntry"
            }
        }
    }
}

List is actually ok, but I think it's a happy accident, map is clearly wrong.

Is there any way to make it work? In Spring I used OpenAPI ModelConverters, it was painful, but it worked. Here I literally cannot find anything. The only thing I found here is mp.openapi.schema. but I'm not even sure if it works in Quarkus, or how to write it so it handles VAVR list/map.

I also tried to remove artificial types (ListCustomerEntry - no idea why it generates like that), so they are inlined like below - no success.

"properties": {
  "customers": {
    "type": "array",
    "items": {
      "$ref": "#/components/schemas/CustomerEntry"
    }
  }
}

0

There are 0 answers