3

I am struggling with my API-spec for my API that returns a HashMap<String, List>. THe API itself works exactly as I want it to, but I want the OpenAPI to correctly specify the return type. I have been googling and found the SchemaType.ARRAY, which made it better, but now when I look in Swagger it is specified as an array, which is closer to the HashMap I want rather than one single Object that it was before I changed SchemaType.

'''

@GET
@Path("/")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
@Operation(
        summary = "All grunddata forapplikationen")
@APIResponse(            responseCode="200",
        description="All grunddata in the system",
        content= @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = Grunddata.class))
)

'''

One promissing solution I found when searching was to make a clss that extends HashMap<String, List> and use it was implementation, but that only resulted in that the API seemed to retrun only a simple String.

0 Answers0