Questions tagged [nswag]

NSwag is a Swagger 2.0 API toolchain for .NET, TypeScript and other platforms, written in C#. The Swagger specification uses JSON and JSON Schema to describe a RESTful web API. The project provides tools to generate Swagger specifications from existing Web API controllers and client code from these Swagger specifications.

The project combines the functionality of Swashbuckle (Swagger generation) and AutoRest (client generation) in one tool chain. This way a lot of incompatibilites can be avoided and features which are not well described by the Swagger specification or JSON Schema are better supported (e.g. inheritance, enum and reference handling). The NSwag project heavily uses NJsonSchema for .NET for JSON Schema handling and C#/TypeScript class/interface generation.

http://NSwag.org

283 questions
3
votes
1 answer

Is it possible to group API operations by assemblies rather than controllers using NSwag in the Swagger UI?

I would like to group all API calls originating from an assembly to display together on the Swagger UI but see the grouping occurs at the controller by default. Any way to force the grouping to be at the assembly level? I am using NSwag to generate…
KNat
  • 31
  • 2
3
votes
1 answer

NSwag customizing JSON output

I have a class: class Test { public IPAddress Ip {get; set; } } By default, Nswag (Nswag.AspNetCore package) at http://localhost:1234/swagger serializes it as so, in the preview "Example" output: [ "Ip": { "AddressFamily": 0, …
zyash
  • 702
  • 6
  • 24
3
votes
1 answer

Swagger/NSwag: Redefine Parameter Type

We are using swagger / nswag for documentation of a webapi project. As BodyParameters for the ActionMethods we use classes with the suffix Command, that contain parameters for e.g. creating a Domain-Object persisted in a database. A Command-Class…
Tobias
  • 2,837
  • 5
  • 34
  • 55
3
votes
3 answers

NSwag multiple document endpoint

It's possible to have multiple document endpoint like in swashbuckle? options.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1"); options.SwaggerEndpoint("/swagger/v2/swagger.json", "API v2"); If Yes, how to decorate api calls so that some…
shadowsheep
  • 10,376
  • 3
  • 44
  • 65
3
votes
2 answers

NSwag not working with ASP.NET Web API 2 and OWIN. Just getting 404

I am trying to get NSwag setup on a new Web API project using OWIN with no luck. I am wondering if the docs aren't mentioning something or I've missed a step. I'm following the instructions from the Middlewares Wiki, but when I load the default…
mikesigs
  • 7,762
  • 3
  • 30
  • 37
3
votes
0 answers

T4 errors when run, but not when debugged

I'm trying to write a .tt file using NSwag, and when I run the Custom Tool, I get this error: Running transformation: System.IO.FileNotFoundException: Could not load file or assembly 'NSwag.CodeGeneration, Version=6.6.6124.16498, Culture=neutral,…
M Kenyon II
  • 3,724
  • 4
  • 35
  • 83
3
votes
2 answers

MSBuild, how to get all project references from .csproj

Is there any variable or property which i could use in msbuild command to get all project references from .csproj? NSwag.exe webapi2swagger /assembly:@(GimmeAllReferencies?) /controller:Namespace.MyController…
shrubbery
  • 31
  • 3
2
votes
1 answer

ASP.NET core: NSwag vs. Swashbuckle

we're currently using Swashbuckle.AspNetCore for API documentation purpose, but when it comes to generation of client-side models (Typescript) it seems there is a major drawback of it. As a sample, I enhanced the known ASP.NET default project…
clemensoe
  • 128
  • 7
2
votes
1 answer

Documenting multiple possible return types in Swagger

Please consider the following method: [HttpGet("abc")] public List GetThemAll() There are 3 types that derive from BaseClass. I would like to provide documentation for the 3 available types. Q: Is it possible to provide documentation for…
tymtam
  • 20,472
  • 3
  • 58
  • 92
2
votes
0 answers

Circular problem when using NSwag.MSBuild

I currently have two projects: 1. ASP.NET Core 3.1 Web API + Xamarin I am using NSwag to automatically generate the C# client in the first project. This is done using an MSBuild target which generates code into a C# Client project. This client…
hyvte
  • 153
  • 1
  • 10
2
votes
1 answer

C# Swagger generated client how to authenticate and use autogenerated code

I have sucessfully generated classes from Swagger Definition (Openapi 3.0.3) using nSwag Studio, but I have no idea how to properly use this as a client. Manually RestSharp code works fine, but I'd like to use autogenerated code to consume…
mr R
  • 747
  • 2
  • 8
  • 21
2
votes
2 answers

NSwag add x-enum-varnames tag to all enums

Is it possible to add x-enum-varnames to all enums in NSwag? I have this example but then you have to specify all the enums. Is there a more generic solution? Also, this example creates a second instance ResultCode2 which I don't…
rhedin
  • 21
  • 3
  • 17
2
votes
1 answer

How to configure NSwag.msbuild to work across platform building net.core projects?

I would like to be able to drop nswag.json and swagger.json in my rest clients project and get the cs code generated automatically. Also if the project is up-to-date don't build it again.
Calin Pirtea
  • 889
  • 6
  • 10
2
votes
0 answers

How to declare Nullable response types in SwakshBuckle (generating clients in NSwagStudio)

We use SwashBuckle to configure our AspNet Core (Service fabric) project to generate Swagger json and UI. Then we use NSwagStudio to generate typescript and C# clients out of nswag.json template with swagger generated by Swashbuckle. Recently there…
Hari
  • 374
  • 1
  • 6
  • 18
2
votes
0 answers

Open API 3 spec generation - ASP.Net Web API 2

Is there support in Swashbuckle or NSwag Nuget packages to generate OpenAPI spec 3 compliant definition for APIs written in ASP.Net Web API 2 (.Net framework 4.7). I tried using Swashbuckle and NSWag Nuget packages but I could get Swagger 2.0…
Gireesh
  • 21
  • 2