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
1
vote
0 answers

Adding securityDefinitions to generated Swagger JSON document using NSwag command line

I have a Web.Api/OWIN project that I'm trying to generate a Swagger spec for. I'm trying to avoid integrating too much of NSwag into my project; the project is an embedded API and I want to avoid having the spec file or Swagger UI run in-process.…
Aleks
  • 1,629
  • 14
  • 19
1
vote
1 answer

NSwag Wep Api 2 multipart/form-data Attribute / file upload

I am trying to setup a Controller Method with NSwag where I can Upload a multipart/form-data file [HttpPost] [Route("{number:long}")] [ValidateMimeMultipartContentFilter] [SwaggerResponse(500, typeof(string), Description = "Error")] …
squadwuschel
  • 3,328
  • 3
  • 34
  • 45
1
vote
1 answer

How do I use Swagger with dynamic parameters from a Web API Action Method?

I write my Web API controllers in a non-standard way where I get the parameters as dynamic objects. This creates an issue with NSwag. Because there are no parameters in the method definition, NSwag cannot generate what is needed. I wonder if there…
realPro
  • 1,713
  • 3
  • 22
  • 34
1
vote
1 answer

Inheritance and discriminator in base class

I have class operation: public class Operation { public string Type { get; set; } public OperationOptions Options { get; set; } } Where value of Type defines type of Options. But I have to add discriminator to OperationOptions…
Backs
  • 24,430
  • 5
  • 58
  • 85
1
vote
1 answer

NSwagStudio using common C# shared library

I'm wanting to use a shared DLL between my endpoint REST service and my client. Both are written in dotnet core. I dont want the generated nswag c# to include these objects defined in the shared DLL but instead just reference them. This way I…
reven
  • 330
  • 4
  • 14
1
vote
0 answers

NSwag doesn't render UI on .Net core 2.1

Recently I have installed NSwag.AspNetCore to my ASP.Net Core 2.1 project to generate api document, This is my source code in Startup.cs file: public void ConfigureServices(IServiceCollection services) { // Add swagger. …
Redplane
  • 2,971
  • 4
  • 30
  • 59
1
vote
1 answer

NSwag filter namespace

I am using NSwag to generate swagger api docs in an ASP.Net Core 2.1 project, which has mixed Web-API controller, MVC controller and Razor Pages. NSwag complains a lot about like the following, while they are valid in ASP.NET. Question: how to filer…
Jiping
  • 700
  • 1
  • 9
  • 12
1
vote
0 answers

Invalid client generated by NSwagStudio

I'm using NSwagStudio to generate a client for my WebAPI (.NET Core 2.0). Unfortunately the generated client is useless. For example: [Route("v1/documentsets")] . . . [Route("")] [HttpGet] [Authorize(Policy =…
Wiggin77
  • 11
  • 2
1
vote
1 answer

NSwag client/server using shared library and same types

I have a shared library between my client and my server. It doesn't contain much, keeping it as small as possible. However all my enums are stored in this shared library. I do this because some of my shared functions need to know/use the…
reven
  • 330
  • 4
  • 14
1
vote
1 answer

Is it possible to auto-generate custom HTTP Headers using nswag (TypeScript)

I use nswag npm package to generate http services, interfaces, etc. The typescript code for a typical service proxy looks as follows: @Injectable() export class TenantsServiceProxy { ... constructor(@Inject(HttpClient) http: HttpClient,…
Alex Herman
  • 2,708
  • 4
  • 32
  • 53
1
vote
0 answers

ASP.NET Core 2 - Angular & JWT Authentication

Problem: I seem unable to fetch the User or any user-related data (e.g. UserID) in any controller after the token has been recorded to browser local storage. I've set a breakpoint and studied HttpContext member of ControllerBase instance (the client…
Alex Herman
  • 2,708
  • 4
  • 32
  • 53
1
vote
1 answer

ActionResult in vanilla ASP.NET (non ASP.NET Core)

I'm trying to integrate Swagger into a somewhat big vanilla ASP.NET MVC app. I was going to use Swashbuckle or NSwag after reading this article. The problem is my controllers are inhereted from the generic base class like this: public class…
SimpleV
  • 396
  • 4
  • 14
1
vote
0 answers

How to override an automatically generated method using "nswag"?

I've reported a bug recently in the nswag library when using object as a property in a DTO class. Till they fix it, is there any workaround or a way to override the generated code in the proxy service?
Homam
  • 23,263
  • 32
  • 111
  • 187
1
vote
2 answers

Angular 5+ consume data from asp.net core web api

I have a problem consuming data from an ASP.NET Core 2.0 Web API with Angular 5+. Here the steps i have done: I have built an ASP.NET Core 2.0 WebAPI and deployed it on a server. I can consume data from postman or swagger without any problems. Then…
Leon
  • 443
  • 5
  • 19
1
vote
1 answer

Using npm nswag to generate TypeScript files from Swagger .json files containing OData values

I am using npm nswag to generate a TypeScript file from a Swagger .json file with the swaggerToTypeScriptClient code generator. There is a problem when it comes across OData properties contained in the JSON. When it generates the interface, the…
Paul
  • 11
  • 2