1

I'm having trouble finding a solution to documenting a Map<String, List<Thing>> properly using Swagger annotations and Open API. Thing is annotated properly, but I cannot find the correct combination of properties in @Schema to document the key and value properly.

I have this property:

@Schema(
  description = "Groups and the things that belong to them.",
  example = "{\"group1\": [{\"name\":\"foo\", ...}, ...], ...}"
  requiredMode = REQUIRED)
private Map<String, List<Thing>> groups;

Key is the group name, value is a collection of things belonging to the group. While defining example kind of helps in the documentation, it shows up as a string of JSON in the example Redocly produces. I don't like that as it's not really accurate.

I've tried various things like additionalPropertiesSchema = Thing.class but that loses representation of the List that's nested inside the map's value.

1
  • Apparently there is request in their tracker. It have no response. Commented Sep 16 at 6:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.