how to overwrite the default key value if the field type is Map<String, T> and you're using springdoc-openapi?

119 Views Asked by At

In the project we're using a generic response body as return type for all endpoints (rest api with spring boot):

public class GenericResponse<T> {

    private UUID id;
    private Map<String, T> data;
}

The idea is having this output in swagger:

enter image description here

But we're getting this:

enter image description here

"additionalProp1" must be a default value, there's no way the library can know this runtime value so it uses that default.

My question is: how can I indicate to springdoc-openapi library what value to put instead? Have in mind that in this specific case I'm using "cart" as key but in others I might need other value, so it must be kind of "dynamic".

0

There are 0 best solutions below