0

I'm trying to correctly annotate a method in one of my Grails controllers for swagger. It's a "GET" endpoint, to search for data using a number of different parameters. These parameters are defined in a command object which is the input to the method. For other endpoints, where we have one or more basic input parameters, Swagger understands correctly that these are request parameters (path). However, when using a command object, Swagger thinks the input is of body type. How can I annotate either my endpoint or my command object model so that Swagger displays each field in the command object as a path parameter?

Endpoint definition:

@ApiOperation(
        value = "Hent liste af Lokalplan",
        notes = "Hent en liste af Lokalplan, der matcher input filter.",
        httpMethod = "GET",
        nickname = "/lokalplan/hent")
    @ApiResponses([
        @ApiResponse(code = 200, message = "Succesfuldt gennemført søgning og hentet matchende planer",
            response = LokalplanDTO, responseContainer = "list"),
        @ApiResponse(code = 400, message = "Hvis input ikke opfylder alle krav"),
        @ApiResponse(code = 403, message = "Hvis brugeren mangler privilegier eller adgang til kommune."),
        @ApiResponse(code = 500, message = "Hvis der sker en integrationsfejl")
    ])
    def hent(HentPlanerAPICommand cmd) {
        hentPlaner(LokalplanDTO, Plantype.LOKALPLAN, cmd, [Rolle.PLEJ_LOKALPLAN_INDBERETTER, Rolle.PLEJ_LOKALPLAN_READONLY])
    }

Here, I want all the fields of HentPlanerAPICommand to each be displayed as path parameters in Swagger, but currently it believes its a body parameter:

enter image description here

If a method is defined in the following way, Swagger correctly understands that planId is a path parameter:

def opdater(Integer planId) {
    opdaterPlan(LokalplanOpdaterDTO, planId, [Rolle.PLEJ_LOKALPLAN_INDBERETTER], STATUSER_FOR_OPDATERING)
}
Zorobay
  • 557
  • 1
  • 6
  • 23

0 Answers0