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

414 questions
0
votes
2 answers

Why is my origin null in asp net core 3, and not localhost

I have been having trouble getting my CORS requests to work between an asp net core API and an Angular 8 app using a generated Nswag typescript client. Just now I figured out why. My origin is "null". Not http://localhost:4200 as I expected it to…
JensB
  • 6,663
  • 2
  • 55
  • 94
0
votes
0 answers

nswag - provide custom json schema

Can I use nswag but providing my own json schemas for the data types? How do I do this, there are multiple files? I am also attempting to use embedded resources as the source from a shared library. Using .net framework. Tried using type-mapper but…
llarsson
  • 33
  • 7
0
votes
0 answers

Nswag - message in attribute "obsolete" is not exist in the generated client

I use Nswag for generate clients. In my controller method marked as [Obsolete("Reason")] but in generated client for it 'obsolete' attribute without comment. [System.Obsolete] and clients is not see reason why this method deprecated. Is there a way…
Sfinks
  • 1
0
votes
1 answer

How to force NSwag and ng-swagger-gen to generate child class property in interface

I use NSwag to generate swagger document in .net core API and ng-swagger-gen for Angular client. The problem is that the generated interfaces ignore child class properties. See this example: //Backend classes public class Student:User{ …
Bellash
  • 7,560
  • 6
  • 53
  • 86
0
votes
2 answers

How does NSwag works in ASP.Net Zero framework?

I tried working on an ASP.Net Zero and it works and I have used its built in PowerTools to create CRUD functionalities of the system. And I tried adding some manual front-end Angular UI in the client side of the application. I'm just not sure what…
0
votes
1 answer

Howto prevent null values in querystring with NSwag

I use NSwag to generate TypeScript code. The generated nswag code sends null when I use an nullable int in a Web API. How do I prevent NSwag to generated this code or allow .NET Core 3.1 to accept this as a valid…
Thom Kiesewetter
  • 6,703
  • 3
  • 28
  • 41
0
votes
2 answers

System.Net.Http.HttpClient cannot connect to web API via NSwag client (Windows Universal Platform)

I wrote a simple .Net Core 3.0 API using Swashbuckle Swagger and generated an api client via NSwag Studio, then I put a generated Api Client to a .Net Standard 2.0 project. I have a Universal Windows Platform application, which is meant to be…
Hantick
  • 63
  • 7
0
votes
1 answer

How can I get NSwag to recognise the "application/json" return type on a POST route?

[HttpPost] [ProducesResponseType(StatusCodes.Status201Created)] [Produces("application/json")] public async Task Post(string filename = null, bool transmit = true) NSwag isn't recognising the…
nathanjw
  • 832
  • 2
  • 13
  • 23
0
votes
1 answer

How to add custom operations to with NSwag

I'm trying to add a route that isn't a Controller into my NSwag generated Open API document. I tried implementing IDocumentProcessor but the operations collection there is immutable. How can I add an additional, non-Controller operation to the…
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
0
votes
1 answer

(C#) Error with building multiple target frameworks: "Cannot open 'MyApi.dll' for writing"

I am following this guide to automatically generate an API client with NSwag. But this client needs to support multiple target frameworks: netcoreapp2.2;net452;net462;net472;net48 When I try to build this…
Mark
  • 1,115
  • 1
  • 7
  • 13
0
votes
1 answer

Use Nswag Console (from NPM package) in order to generate C# client

According to the official Nswag command line docs it is possible to use Nswag via NPM console package (and subsquently generate C# client using openapi2cscontroller): To use the command line tool nswag.exe (.NET 4.6+) / dotnet-nswag.dll (.NET…
wondra
  • 3,271
  • 3
  • 29
  • 48
0
votes
0 answers

Can't import JSON file when referencing to another file

I'm using NSwag.OpenaPiDocument.FromJsonAsync() to load a JSON file. The JSON file is seperated in several files. Unfortunately, I'm getting this error: Could not resolve the JSON path 'parameters.json#/tagsParam' with the full JSON path…
Rudi
  • 926
  • 2
  • 19
  • 38
0
votes
0 answers

Nswag/Swashbuckle ASP net core openApi document with dynamic request branch logic

If you have controller which doesn't include mapped branch then how to support that in openAPI document generated by Nswag or Swashbuckle? I have tried reverse proxy thing but it is not working. Consider C# ASP.NET Core 2.2 for C# code. For example,…
Bhavy Bhut
  • 43
  • 1
  • 5
0
votes
1 answer

Adding JWT Bearer Authorization to NSwag 13

We were using NSwag 11 and trying to move to the 13th that seems to use quite different calls. The old-style code looks kind of public static class SwaggerServiceExtensions { public static IServiceCollection AddSwaggerDocumentation(this…
Boris Sokolov
  • 1,723
  • 4
  • 23
  • 38
0
votes
1 answer

MSBuild: how to include generated classes into compilation?

I have the following MSBuild script: ... NSwag; $(BuildDependsOn)
Chris W
  • 1,562
  • 20
  • 27