Swagger: Spring MVC models in GET request

Viewed 5673

In MVC, you would expect that controller will receive models as input and produce models as output. In Swagger, the latter is not a problem but I have troubles with former. I can't understand how to make Swagger build an input model from incoming GET parameters.

Consider:

"paths": {
    "/search": {
        "get": {
            "consumes": [],
            "produces": [
                "application/json"
            ],
            "parameters": [
                // What goes here?
            ],
            "responses": {
                "200": {
                    "description": "Success",
                    "schema": { 
                        "$ref": "#/definitions/SearchResponse"
                    }
                },
            }
        }
    }
}

How do I make the generated controller's method to have a signature like:

    public ResponseEntity<ResultModel> controllerGet(ModelFromParameters input);

where ModelFromParameters will have several fields corresponding to different GET parameters.

Examples mostly focus either on POST requests, or GET requests where every of 20-odd parameters are stuffed in the arguments list of method, which is obviously anti-MVC.

The API in question is a complex stateless querying system with a lot of parameters.

4 Answers
Related