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
15
votes
3 answers

how to inject API_BASE_URL (a string) in an angular service

this autogenerated service (by NSwagStudio) needs an API_BASE_URL (InjectionToken) value in order to perform http requests how and where i can inject it? /* tslint:disable */ //---------------------- // // Generated using the…
alex
  • 1,304
  • 3
  • 22
  • 50
14
votes
4 answers

What is the correct way to download a file via the NSwag Code Generator (angular 2 typescript)

I try to download a file via an angular 2 typescript client. The link generated in Swagger UI works fine, but the generated typescript client does not. The controller looks like this: [HttpGet("export")] [SwaggerResponse((int)…
lama
  • 262
  • 2
  • 9
14
votes
3 answers

Is it possible to have NSwag ignore a controller?

I used NSwag to generate a client for a single controller; I needed it as its own separate client. I would like for it to be ignored when the Swagger specification is generated in the future. I tried adding this attribute at the top of the…
James B. Nall
  • 1,088
  • 2
  • 16
  • 22
14
votes
3 answers

How to invoke a NSwag client method that needs bearer token on request header?

I didn't get exactly how NSwag interact with IdentityServerX bearer tokens and adds it request header conventionally? My host api application implements IdentityServer3 with LDAP auth, so as far as i understand; if any host needs to a token for…
Oğuzhan Soykan
  • 2,072
  • 1
  • 15
  • 30
12
votes
1 answer

How to include Http request method name in client method names generated with NSwag

When I generate a C# client for an API using NSwag, where the API includes endpoints that can be used with multiple Http request types (e.g. POST, GET) the client generates a method for each request with the same base name, plus a number. E.g. Using…
Ergwun
  • 11,590
  • 7
  • 49
  • 79
9
votes
2 answers

C# NSwag and swagger-codegen with Enums

I have a .Net Core v2.1 Web API which uses NSwag to generate its Swagger Json. I have a response model as such - public class LoginResponse { public LoginResult LoginResult { get; set; } } public enum LoginResult { AwaitingEmailConfirmation…
WickedW
  • 2,123
  • 3
  • 21
  • 46
9
votes
2 answers

How to use a custom model binder with Swashbuckle, Swagger and NSwag?

I have an ASP.NET Core Web API that contains the following endpoint. [HttpGet] [Route("models/{ids}")] [Produces(typeof(IEnumerable))] public IActionResult Get ( [ModelBinder(typeof(CsvModelBinder))] IEnumerable ids ) { …
Raymond Saltrelli
  • 3,735
  • 2
  • 25
  • 43
8
votes
1 answer

C# How to handle polymorphic models using NSwag

I have a polymorphic model: public class CreateOrderRequest { public List OrderItems { get; set; } } /// /// Identifies a new item within an order ///
6footunder
  • 1,120
  • 14
  • 25
8
votes
3 answers

NSwag namespace in model names

It's possible to generate client code so that model's class names have full namespaces as prefix? That should avoid same class name conflicts. Example com.foo.MyClass and it.foo.MyClass Up to now what I got is MyClass and MyClass2 that's not so…
shadowsheep
  • 10,376
  • 3
  • 44
  • 65
7
votes
2 answers

NSwag .NET Core API Versioning configuration

I'd like to prepare my .NET Core Web API project so that multiple versions of the API can be managed and documented, according to the REST services standards. I'm using .NET Core 2.1 with NSwag (v11.18.2). I also installed the…
Cheshire Cat
  • 1,658
  • 2
  • 29
  • 58
6
votes
1 answer

How can i disable / handle init, toJSON

I've created a .NET core 2.2 webapi, and using swagger / nswag to generate the API for my React / typescript application. When I try to set up a new object I get a ts(2739) message: Type '{ firstName: string; lastName: string; }' is missing the…
RMCS
  • 343
  • 2
  • 14
6
votes
1 answer

Is it possible to use Swagger with AspNetCore Odata?

Yesterday I searched solution how to use swagger on Core Odata, I tried few libraries but with no success, it seams that currently it's not fully supported.
5
votes
2 answers

How can I change the default info title produced by nswag?

I'm using NSwag for .NET Core 3.1. Everything works correctly. I can't determine how to change "My Title" (which is the info title) to something else. Here is the swagger page: Here is my registration code: app.UseOpenApi(); app.UseSwaggerUi3(c =>…
N-ate
  • 3,202
  • 26
  • 37
5
votes
1 answer

Generate NSwag client as part of the build

I have a project that uses NSwag to generate a client and the contracts from a swagger file. I don't want these generated files to be tracked by git, so that when the project is built on the build server, it generates them as part of the build. I've…
Tom
  • 1,411
  • 4
  • 18
  • 29
5
votes
1 answer

Set Bearer Token with nswag in ASP.NET Core 2.2

I have an ASP.NET Core 2.2 Web Api and I added the swagger support with nswag. The web api is protected using a local IdentityServer4 that generates access tokens. I found the code to add an authorization button and form and set the bearer token in…
1
2 3
18 19