Search code examples
javajax-rsenunciate

Define Enunciate response of Map<String, String>


The closest response data type description I can get is

map of object (JSON)

with a response example of

...

when I use the annotation

@TypeHint(Map.class)

Ideally I need to specify a response type of Map<String, String>, HashMap<String, String>, or something that would provide a response data type that makes sense and a response example similar to

{
    "...": "...",
    "...": "..."
}

Solution

  • Found a solution using the @requestExample JavaDoc Tag detailed in the Enunciate documentation.

    For example

    @responseExample application/json {"..." : "..."}
    

    Gives a proper response example of

    {
      "...": "..."
    }
    

    Using the @TypeHint(Object.class) annotation produces a response data type of object (JSON), which technically makes sense, so this solution is sufficient.