1
votes

I'm trying to generate client code for C#/asp.net core to consume a service that has a swagger 1.1 specification. (The service is out of my control). Unfortunately most up-to-date tools require at a swagger 1.2 spec. Most tools even require open-api 2.0. Even most converters start at 1.2. Does anybody know a tool to upgrade from 1.1 to 1.2?

I'd even consider a manual rewrite, but I can't find anywhere what changed between 1.1 and 1.2

1

1 Answers

2
votes

First of all, 1.2 is also a very old version. Consider converting to OpenAPI 2.0 (used by most tools nowadays) or maybe even OpenAPI 3.0 (the latest version).

Swagger Codegen

Swagger Codegen can generate client/server code from 1.x-3.0 specs, and can also convert Swagger 1.x to OpenAPI 2.0 or 3.0.

To generate a C# client from a Swagger 1.x spec using Codegen CLI v. 2.x:

java -jar swagger-codegen-cli-2.4.0.jar generate
     -i http://path/to/spec.json
     -l csharp
     -o ./csharp-client

To convert Swagger 1.x to OpenAPI 2.0, Codegen CLI v. 2.x with the -l swagger argument to get JSON or -l swagger-yaml to get YAML.

java -jar swagger-codegen-cli-2.4.0.jar generate
     -i http://path/to/spec.json
     -l swagger
     -o ./converted

To convert to OpenAPI 3.0, use Codegen CLI v. 3.x with the -l openapi argument to get JSON or -l openapi-yaml to get YAML.

java -jar swagger-codegen-cli-3.0.3.jar generate
     -i http://path/to/spec.json
     -l openapi
     -o ./converted

API Transformer

API Transformer claims to support Swagger 1.x -> 1.2 / 2.0 / 3.0 conversion.