NSwag is a comprehensive toolchain designed for generating OpenAPI (Swagger) specifications from ASP.NET Web API controllers and subsequently generating client code in various languages, primarily TypeScript and C#. It supports a wide range of client frameworks including Angular, React, and jQuery, and handles both OpenAPI 2.0 (Swagger) and 3.0 specifications. The current stable version, 14.7.0, reflects active development with frequent minor releases. NSwag differentiates itself through its deep integration with the .NET ecosystem for robust spec generation and its versatile client generation capabilities. It operates predominantly as a command-line interface (CLI) tool, wrapping .NET executables, and crucially requires a compatible .NET runtime (Full .NET Framework 4.6.2+ or .NET 6.0+) to be installed on the system where the CLI commands are executed.
npm install nswagVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to generate a TypeScript API client from an OpenAPI specification using the NSwag command-line tool, including runtime specification and cleanup.
Install a supported .NET SDK (e.g., .NET 8.0 or 9.0) on your system. For specific scenarios, explicitly specify the desired runtime using the `/runtime:` argument, e.g., `/runtime:Net80`.
Ensure your TypeScript project is configured to target at least TypeScript 4.3. If you must support older TypeScript versions, you may need to manually adjust the generated client code or stick to an older NSwag version.
Explicitly specify the runtime in your command, e.g., `nswag run /runtime:Net80`. If using the global .NET tool, ensure it's installed with the correct framework, e.g., `dotnet tool install --global NSwag.ConsoleCore --version <version> --framework net8.0`.
Upgrade NSwag to version 14.6.3 or higher to incorporate the necessary security fixes and ensure generated clients or specifications are not derived from vulnerable components.
Upgrade to NSwag v14.6.2 or a later version. If customization is needed, refer to the documentation for the `JsonLibraryVersion` configuration.
If running NSwag as a global .NET tool, install it with the specific framework: `dotnet tool install --global NSwag.ConsoleCore --version <version> --framework net8.0`. If using the npm package, ensure the runtime argument is correctly formatted and supported for the specific NSwag version.
Install NSwag globally using `npm install -g nswag`. Alternatively, if installed locally (`npm install nswag --save-dev`), invoke it via `npx nswag` or by providing the full path: `"./node_modules/.bin/nswag"`.
Upgrade NSwag to version 14.7.0 or higher, which includes a fix for this specific Axios template issue.
Review and update your `nswag.json` configuration file to match the requirements of your NSwag and .NET versions. This may involve removing deprecated settings or adjusting schema generator properties, as some settings were moved in NSwag v14.
No dependency data recorded yet.