我正在尝试使用OpenAPI 3.0创建Swagger文档。我使用的是spring-boot-starter****1.5.4.RELEASE和springdoc-openapi-ui版本1.4.2
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.4.2</version>
</dependency>
我的代码如下:
@SpringBootApplication
@OpenAPIDefinition(info = @Info(title = "test", version = "2.0", description = "sample description3"))
public class SwaggerSpringDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SwaggerSpringDemoApplication.class, args);
}
}
@RestController
@RequestMapping("/")
public class PersonController {
@RequestMapping(value = "/{operationType}/{listName}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED)
@CrossOrigin
public String rollingUpgrade( @PathVariable String operationType, @PathVariable String listName,
@RequestParam(value = "rowData") String rowData) throws Exception {
..........
return "";
}
}
运行应用程序时,出现以下错误:
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
但是,如果我形成类似value =“test/{operationType}/{listName}”的url,问题就解决了
我不知道这到底是什么原因。
1条答案
按热度按时间xwbd5t1u1#
试试上面这个注解控制器的方法:
查看Swagger UI,尝试不设置内容类型