0

I know the nswag can show the api doc but why we should use it to generate code?

Just to generate the CUDA code?

Is it useful?

liang.good
  • 213
  • 3
  • 12

2 Answers2

3

Introduction from official documents

NSwag is open source project for generating Swagger documents and integrating Swagger UI or ReDoc into ASP.NET Core web APIs. Additionally, NSwag offers approaches to generate C# and TypeScript client code for your API.

NSwag offers the following capabilities:

  • The ability to utilize the Swagger UI and Swagger generator.
  • Flexible code generation capabilities.

With NSwag, you don't need an existing API—you can use third-party APIs that incorporate Swagger and generate a client implementation. NSwag allows you to expedite the development cycle and easily adapt to API changes.

NSwag’s client generation seems to be an easy way to get started consuming API’s. It allows us to generate both on the fly, and prior to compilation. By generating quality source code, in developer-friendly format, modern code generators force multiply the efficiency of full stack developers while providing a modern highly scalable and robust baseline codebase.

Michael Wang
  • 3,782
  • 1
  • 5
  • 15
1

It is useful to generate automatically:

  • documentation
  • tests
  • mock servers

We can define the whole API with types and examples for every endpoint before we start implementing it. With tools that generate mock-APIs, we can verify that everything looks the way we intended. We can refine our API design by simply iterating over the specification document.

D A
  • 1,724
  • 1
  • 8
  • 19