4

What is the difference between Swagger UI vs Swagger CodeGen?

I read the description in https://swagger.io/tools/. It sounds like Swagger Editor, UI, and codeGen are totally different tools. If I want to generate .Net server stubs and visualize them, does it mean I need to use both UI and CodeGen?

Cloe
  • 61
  • 1
  • 2

1 Answers1

9

Yes, they are different tools for different purposes.

Swagger UI is a documentation renderer, basically an HTML page. You point it to an OpenAPI definition (YAML or JSON file), and Swagger UI produces API documentation that looks like this. You can host it on your website.

Swagger Editor is an editor where you can write OpenAPI definitions manually, or load/paste arbitrary OpenAPI definitions to check them for syntax errors. Swagger Editor also has Swagger Codegen integrated into it, accessible via the "Generate Server" and "Generate Client" menus.

Swagger Codegen is a code generator. You can use it to generate server stubs and client SDKs from an OpenAPI definition. For example, here's how to generate an ASP.NET server stub using Swagger Codegen CLI (line breaks added for readability):

java -jar swagger-codegen-cli-3.0.21.jar generate
     -i https://petstore.swagger.io/v2/swagger.yaml
     -l aspnetcore
     -o .\aspnetcore-server
Helen
  • 87,344
  • 17
  • 243
  • 314