Java 大摇大摆的人不';t显示OpenApi codegen正确生成的文档化API
我正在使用openapi生成器maven插件从YAML文档生成代码Java 大摇大摆的人不';t显示OpenApi codegen正确生成的文档化API,java,swagger,swagger-ui,openapi,openapi-generator,Java,Swagger,Swagger Ui,Openapi,Openapi Generator,我正在使用openapi生成器maven插件从YAML文档生成代码 openapi: 3.0.3 info: title: Example API Doc description: Those are example endpoints. termsOfService: https://localhost:8080/termsOfService license: name: No license url: https://localhost:8080/licens
openapi: 3.0.3
info:
title: Example API Doc
description: Those are example endpoints.
termsOfService: https://localhost:8080/termsOfService
license:
name: No license
url: https://localhost:8080/license
version: 1.0-SNAPSHOT
servers:
- url: https://localhost:8080/
- url: http://localhost:8080/
tags:
- name: example
description: Example Tag
paths:
/example:
get:
tags:
- example
summary: Example GET request
description: Send example GET request
operationId: exampleGetRequest
responses:
200:
description: Successful operation
content: {}
400:
description: Example Bad Request
content: {}
404:
description: Example Not Found
content: {}
以下是我如何配置maven插件以生成接口:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.1.1</version>
<configuration>
<generatorName>spring</generatorName>
<inputSpec>${project.basedir}/src/main/resources/exampleApi.yaml</inputSpec>
<apiPackage>com.example.openapi.generated.api</apiPackage>
<modelPackage>com.example.openapi.generated.models</modelPackage>
<generateSupportingFiles>false</generateSupportingFiles>
<output>${project.basedir}</output>
<configOptions>
<dateLibrary>java8</dateLibrary>
<java8>true</java8>
<interfaceOnly>true</interfaceOnly>
</configOptions>
</configuration>
</plugin>
org.openapitools
您好,我也有同样的问题。你找到解决办法了吗?嗨,我不确定它是否解决了问题,因为从那一刻起我改变了很多事情。尝试将实现类注释为@Controller
,而不是@RestController
。另外,我的接口现在没有默认方法,所有端点方法声明都是“抽象的”,正如您在接口中所说的那样。如果它对您有效,请在这里为其他人提供答案。您好,如果我将实现类注释为@Controller swagger ui显示“规范中未定义任何操作”。我将两个设置“interfaceOnly”和“skipDefaultInterface”都设置为“true”。嗨,我遇到了同样的问题。你找到解决办法了吗?嗨,我不确定它是否解决了问题,因为从那一刻起我改变了很多事情。尝试将实现类注释为@Controller
,而不是@RestController
。另外,我的接口现在没有默认方法,所有端点方法声明都是“抽象的”,正如您在接口中所说的那样。如果它对您有效,请在这里为其他人提供答案。您好,如果我将实现类注释为@Controller swagger ui显示“规范中未定义任何操作”。我将两个设置“interfaceOnly”和“skipDefaultInterface”都设置为“true”。
@Api(value = "example", description = "the example API")
public interface ExampleApi {
default Optional<NativeWebRequest> getRequest() {
return Optional.empty();
}
@ApiOperation(value = "Example GET request", nickname = "exampleGetRequest", notes = "Send example GET request", tags = {"example",})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful operation"),
@ApiResponse(code = 400, message = "Example Bad Request"),
@ApiResponse(code = 404, message = "Example Not Found")})
@RequestMapping(value = "/example", method = RequestMethod.GET)
default ResponseEntity<Void> exampleGetRequest() {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
}
@RestController
public class ExampleApiImpl implements ExampleApi {
@Override
public ResponseEntity<Void> exampleGetRequest() {
return ResponseEntity.ok().build();
}
}