Search code examples
.nettypescriptswaggeropenapiautorest

Generating autorest client from different OpenAPI versions


I'm looking into generating a Typescript client from our .NET API, I landed on using Autorest since it's built with Node (Which I'm familiar with). I also know of Swashbuckle but I'm not familiar with Java.

Our API is versioned, most endpoints are on V1 (e.g. /v1/users), but certain endpoints have been updated and are now prefixed by V2 (e.g. /v2/users).

Swagger/OpenAPI only lists either:

  • http://localhost:5000/swagger/v1/swagger.json
  • http://localhost:5000/swagger/v2/swagger.json

Neither of these JSON files contains all endpoints, they would need to be unified into a single file to have all endpoints availaible.

How do I make Autorest generate clients for both of these at the same time? Generating one then the other overwrites the first so I can't seem to get them to exist at the same time.

What should I do here? Is it the backend's responsibility to make the V2 page list all endpoints from V1? Is there a way to get Autorest to generate both at the same time?


Solution

  • After some research I realised you can either pass multiple --input-file arguments via CLI or you can pass an array to the yaml config:

    input-file:
      [
        http://192.168.125.44:4999/swagger/v1/swagger.json,
        http://192.168.125.44:4999/swagger/v2/swagger.json,
      ]