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
2 answers

Can NSwag be used in a self-hosted .net core API with convential routing?

I have a self-hosted .net core API that I would like to auto-generate an Open API spec from. Swashbuckle does not support generating the spec if you use conventional routing (i.e., using MapRoute instead of attribute routing). Does anyone know if…
Victor P
  • 1,496
  • 17
  • 29
1
vote
0 answers

When change the angular template nswag generated file return result key word not considering

I try to move one angular template to another angular template. after moved i run the nswag file then i run the application. data not mapping because return result contain result keyword but nswag generated file not considering result keyword. i…
Av.Raj
  • 55
  • 9
1
vote
1 answer

nSwag change responseType: "blob"

I have a problem. I am using asp.net core 3 web api. The Angular 8 app client is generated with nSwag version 13.2.1.0. The specificatio is generated Swashbuckle.AspNetCore 5. The result I get is: ** * @param body (optional) * @return…
Wasyster
  • 2,279
  • 4
  • 26
  • 58
1
vote
1 answer

NSwag - Modifying Hosts, Schemes, etc using .NET Framework Global.asax setup

I'm trying to modify the Host, Schemes, BasePath, etc properties on the Swagger Document object. I'm using a Global.asax ASP.NET setup (not Core), setting up the properties through UseSwaggerUi3. I have tried modifying these properties through a…
C. Gordon
  • 11
  • 1
1
vote
1 answer

Angular TypeScript client generated from an ASP.NET Core 3.1 application is not working

I am having difficulties with a generated Swagger Angular client from an Asp.Net Core 3.1. I created an ASP.NET Core application and added the following to the TestController.cs [HttpGet] [Route("TList")] [Produces("application/json")] public…
Nigel Findlater
  • 1,684
  • 14
  • 34
1
vote
0 answers

NSwag Response Headers

How Response Headers can be set in NSwag? I tried to add to OpenApiResponse.Headers collection. var headerSchema = new JsonSchema() { Type = JsonObjectType.String, Description = "headerDescription" …
Ehsan Mirsaeedi
  • 6,924
  • 1
  • 41
  • 46
1
vote
0 answers

Type is not marked as serializable

I am using this command postbuild in .net 4.6.1 web api project. $(NSwagExe) aspnetcore2swagger "/assembly:$(TargetPath)" "/output:$(OutputPath)swagger.json" However it's failing on 2 places, first one is, 1>System.IO.FileNotFoundException: The…
1
vote
0 answers

Data Annotation in NSwag CodeGen Net Core

When i try to convert the below enum property, it doesn't change as expected. I used the nswag to generate the code in typescript from my EF core API, the enum based class doesn't convert as expected when using [DisplayName] or [Description]…
A Coder
  • 3,039
  • 7
  • 58
  • 129
1
vote
1 answer

NSwag adding three parameters to some of my methods

Swagger is adding three extra parameters in the UI. It only does it with two methods. The other three are fine. All are defined pretty much the same way. The only difference I can see is the order of parameters ([FromBody] is first on the…
1
vote
2 answers

Create one code client / flatten controllers with NSwag and AutoREST

I'm trying to create a code wrapper for an api with NSwag and Autorest. Previously I was using Swashbuckle to generate the swagger file. It generated the swagger file with operationIds in the format actionMethod. This resulted in Autorest generating…
farlee2121
  • 2,959
  • 4
  • 29
  • 41
1
vote
1 answer

Specifying API Endpoint at runtime when using NSwagStudio

I have an API client generated by NSwagStudio. My constructor for one of my endpoints looks like this: private string _baseUrl = "http://localhost:11957"; private System.Net.Http.HttpClient _httpClient; private…
Lewis Cianci
  • 926
  • 1
  • 13
  • 38
1
vote
3 answers

How can I use an observable to paginate through data?

I've spent the last few days learning about observables and have started to embrace them in my Angular application. I have a Web API app that I am producing a client for through NSwagClient in typescript. I have an API action that has this as its…
Lewis Cianci
  • 926
  • 1
  • 13
  • 38
1
vote
1 answer

How to unit test nSwag Angular Clients

I am trying to write a simple unit test for a client that was generated with nswag and it look it('it create a call create on the api if new household', async(() => { const newHousehold = new Household(); newHousehold.name = 'Test Household'; …
Jonathan
  • 1,725
  • 3
  • 19
  • 45
1
vote
0 answers

How to run nswag code generating script on MacOS

I'm trying to run a code generating script from terminal within vs code on a mac, but each time I get the the following error: cmd: "..\node_modules\.bin\nswag" run cmd : The term 'cmd' is not recognized as the name of a cmdlet, function, script…
brook yu
  • 13
  • 4
1
vote
2 answers

NSwag: 404 Not Found /swagger/v1/swagger.json on IIS

I have a basic asp.net core 2.1 web API. I installed NSwag.ASPNetCore nuget package. here is my startup.cs. When I run this on IIS Express, swagger is working fine. Once I deploy this to IIS, I am getting 404 not found. Do I need to add a Path…
katie77
  • 1,797
  • 4
  • 25
  • 43