Forum Discussion

suswan86's avatar
New Member
3 years ago

Getting 405 error in OpenAPI swagger page if I put path variable attributes in a Rest Controller

I am trying to create Swagger documentation using OpenAPI 3.0. I am using spring-boot-starter 1.5.4.RELEASE and springdoc-openapi-ui version 1.4.2



My code is as follows:

@OpenAPIDefinition(info = @Info(title = "test", version = "2.0", description = "sample description3"))
public class SwaggerSpringDemoApplication {

    public static void main(String[] args) {, args);

public class PersonController {

    @RequestMapping(value = "/{operationType}/{listName}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED)
    public String rollingUpgrade( @PathVariable String operationType, @PathVariable String listName,
                                @RequestParam(value = "rowData") String rowData) throws Exception {
        return "";

When I run the application, I get the following error:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri May 13 09:58:38 IST 2022
There was an unexpected error (type=Method Not Allowed, status=405).
Request method 'GET' not supported

But the issue is resolved if I form the url like value = "test/{operationType}/{listName}"

I dont know what is the exact reason for this.

No RepliesBe the first to reply