Skip to content
Advertisement

springdoc-openapi swagger don’t make calls with parameters

I have deleted an old swagger in a project and added springdoc-openapi, following the official documentation.

I should have done something wrong, but I don’t know what. Somehow when I try to execute a call, the parameters don’t get replaced in the URL:

enter image description here

As you can see in the image, the curl attach a {id} at the end, instead of 13. If I try this curl myself with the number 13 it works fine.

This is the code for this specific call:

@Operation(summary = "Gets a client.")
    @ApiResponses({ @ApiResponse(responseCode = "200", description = "Ok"),
                    @ApiResponse(responseCode = "404", description = "Not found") })
    @GetMapping(path = "/{id}")
    public ResponseEntity get(@PathVariable @Parameter(name = "ID of client") final Long id) {
        final ClientDTO response = clientService.get(id);

        return ResponseEntity.ok(response);
    }

I am using spring-boot 2.7.3 and springdoc-openapi 1.6.11

Advertisement

Answer

I found out the problem.

I was migrating from mangofactory swagger and the guide I followed was wrong. In @Parameter, it should be ‘description’ instead of ‘name’.

The swagger doesn’t help to find this error because since there is no description, it uses the name. But since in name I am writing the description, it appears as if everything is correct (under description I see my expected String).

Advertisement