整个想法是为 UI 团队创建模拟服务,以便在没有实际 API 的情况下进行测试。
- 我们在 .yaml 文件中定义了规范。
- 现在想要使用模拟数据生成 Swagger-UI 和模拟 REST URI。
- 使用 spring-boot。
请建议一些生成相同内容的方法。
最佳答案
鉴于您已在 Swagger/OpenAPI 规范(YAML 格式)中记录了 API,您可以使用 Swagger Codegen生成 Spring boot 服务器 stub 。
请拉取https://github.com/swagger-api/swagger-codegen最新高手并按照 wiki 中的说明进行操作:
https://github.com/swagger-api/swagger-codegen/wiki/Server-stub-generator-HOWTO#java-springboot
关于spring - 使用 Swagger/OpenAPI 文档模拟 Rest API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38147749/