我们的项目对单个API使用多个swagger文件,但看起来swagger-codegen只接受一个 . 在这种情况下,我们如何使用swagger-codegen生成代码?
您可以使用相对模式文件 . 例如
$ref: 'Pet.yaml'
参考:https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#relative-schema-file-example
如果swagger文件没有相互链接/相关,那么您需要将swagger文件组合到一个文件中并使用 tags 对操作进行分类 . 例如
tags
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml#L14
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml#L32
1 回答
您可以使用相对模式文件 . 例如
参考:https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#relative-schema-file-example
如果swagger文件没有相互链接/相关,那么您需要将swagger文件组合到一个文件中并使用
tags
对操作进行分类 . 例如https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml#L14
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml#L32