嵌套Java Swagger@Operation配置



通过swagger annotations v2.1.5依赖项,我正在尝试构建以下内容:

"x-amazon-apigateway-integration":{
"type":"http",
"httpMethod":"GET",
"uri":"http://<DOMAIN>/api/hello-world",
"responses":{
"default":{
"statusCode":200
}
}
}

下面的Java代码生成上面的JSON,除了";响应";树有人能建议如何在下面的Java代码中添加它吗:

@Operation(extensions = {
@io.swagger.v3.oas.annotations.extensions.Extension(name = "x-amazon-apigateway-integration", properties = {
@io.swagger.v3.oas.annotations.extensions.ExtensionProperty(name = "type", value = "http"),
@io.swagger.v3.oas.annotations.extensions.ExtensionProperty(name = "httpMethod", value = "GET"),
@io.swagger.v3.oas.annotations.extensions.ExtensionProperty(name = "uri", value = "http://<DOMAIN>/api/hello-world")
})
})
@GetMapping(value = "/hello-world")
public ResponseEntity<?> helloWorld() {
return ResponseEntity.ok("Hello World");
}

pom.xml有以下3个依赖项:

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.1.5</version>
</dependency>

请尝试以下操作:

@ExtensionProperty(name = "response", value = "{"default":{"statusCode":200}", parseValue = true)

参考

最新更新