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

How to specify base interface with net5 OpenAPI support

I am trying to adapt a project to .net5 and want to use the new feature of adding an OpenAPI service reference. As far as I understand it, NSwag will be used to generate the client. I already used NSwag for this purpose in the past and I could use…
Daniel
  • 126
  • 7
3
votes
1 answer

NSwag's AspNetCoreOperationSecurityScopeProcessor marks all endpoints as requiring Authorization

I have custom authorization scheme set up like this: services.AddAuthentication("ClientApp") .AddScheme("ClientApp", null); Then I have the following NSwag OpenAPI…
3
votes
1 answer

How to order/sort paths in NSwag swagger.json by controller name

I am using NSwag to generate swagger for my .NET Core api and everything works great, except the fact that paths are rendered in order that reflection seems to pickup Controllers from project. So if I do have hierarchy - some controllers at root…
nikib3ro
  • 19,427
  • 21
  • 113
  • 173
3
votes
0 answers

How to use html markup in the "description" attribute of swagger.json file?

Environment: NSwag.AspNetCore (12.2.5); Microsoft.NETCore.App (3.0.0); Language: C# I am marking the header of some controllers, with the following expression: ///Controller description /// ///
/// …
3
votes
1 answer

Is it possible to ignore a model property in nswag without using [JsonIgnore]?

Using JsonIgnore is not possible in my project and [OpenApiIgnore] does not work. In swashbuckle it was possible to make a filter by its own attribute, but in NSwag I did not find a similar mechanism. Code example: Command class On API…
x666ep
  • 133
  • 1
  • 1
  • 9
3
votes
1 answer

How to include custom statements/directive in C# code generated by NSwag?

I generated C# code from a Swagger definition and was wondering if there is a configuration parameter to automatically include using statements in the generated files. I found this link…
K.Oleksiak
  • 275
  • 2
  • 15
3
votes
1 answer

Make properties in NSwag generated client nullable

I get this object specification in (OpenApi 3.0.1) from a vendor: "ExampleTO" : { "codeValidFrom" : { "type" : "string", "format" : "date" } } NSwag generates this property in a C# client (correctly, I…
TvdH
  • 896
  • 10
  • 27
3
votes
2 answers

NSwag generates multiple functions with the same name when using OpenApi 3.0 JSON file

I am trying to generate the client code in both .NET Core and TypeScript using NSwag CLI: nswag run options.nswag This works correctly for various Swagger 2.0 JSON files, but generates multiple functions with the exact same name for an OpenApi 3.0…
Alexei - check Codidact
  • 17,850
  • 12
  • 118
  • 126
3
votes
0 answers

How to generate client side code with NSwag for web sockets

I'm currently working on a .net core application, we generate the client side code (angular 8 / typescript) with NSwag. We also have a websocket (SignalR). The Angular client app listen for events on the websocket. The websocket events are not…
Mitch
  • 41
  • 2
3
votes
2 answers

How to load custom stylesheet with NSwag's UseSwaggerUi3

I'm trying to customize the swagger UI with my own .css stylesheet. I am using asp net core 2.1 and NSwag.AspNetCore 12.2.5. I've searched around and found that in previous versions this would be done by embedding my custom stylesheet and then…
Patrick
  • 33
  • 3
3
votes
3 answers

How to add custom headers in NSwag document using C# .NET CORE?

I am in need of adding custom headers, but cannot figure it out. I am trying to utilize the new services.AddOpenApiDocument() instead of the services.AddSwaggerDocument(). I want to add these custom headers on my whole API not just a single method…
JVIH
  • 83
  • 1
  • 8
3
votes
2 answers

Generate swagger model for generic parameter from body

I'm currently working on a project where we generate all our controllers automatically. Our BaseController has an action ike this: [HttpPost("")] public virtual Task Create([FromBody] ICreateEntityModel model) …
mvogler
  • 31
  • 2
3
votes
2 answers

ASP.NET Boilerplate: Constraining user Input DTO property value to specific set of values

I've recently started using ASP.NET Boilerplate as a starting point for a project I'm working on - Asp.NET Core Web Api + Angular, and I'm having trouble finding some information regarding something that seems to me like a common use issue. I'll try…
spico
  • 31
  • 1
3
votes
2 answers

How to upload data + multiple files from Angular to .net core Web Api

My server uses .Net Core 2.1.402 Here is my C# class: public class SampleDetailsDto { public Guid Id{ get; set; } public string Text { get; set; } public IEnumerable ImageUrls { get; set; } public IFormCollection Images {…
Cedric Arnould
  • 1,294
  • 15
  • 38
3
votes
3 answers

NSwag: Generate C# Client from multiple Versions of an API

We are versioning our API and generating the Swagger specification using Swashbuckle in ASP.NET Core 1.1. We can generate two API docs based on those JSON specification files: services.AddSwaggerGen(setupAction => { …
Structed
  • 194
  • 6
  • 19
1 2
3
18 19