Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using swagger-codegen with multiple swagger files

Our project uses multiple swagger files for a single API, yet it appears swagger-codegen only accepts one. How do we generate code with swagger-codegen in this case?

like image 409
LookingToLearn Avatar asked Dec 06 '16 04:12

LookingToLearn


1 Answers

You can use relative schema file. e.g.

$ref: 'Pet.yaml'

Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#relative-schema-file-example

If the swagger files are not linked/related to each other, then you will need to combine the swagger files into a single file and use tags to classify the operations. e.g.

  • 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
like image 60
William Cheng Avatar answered Oct 21 '22 19:10

William Cheng