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
1 answer

NSwag generates base class even though JsonSchemaFlattenAttribute is set

I am using NSwag for my ASP.NET Core web api project and just can't get it to work. What I'm trying to do is to exclude some of the base properties of IdentityUser. Here is my custom user class: [DataContract] [JsonSchemaFlattenAttribute] public…
rhedin
  • 71
  • 1
  • 3
  • 20
0
votes
0 answers

Multiple separate Swagger documentations: internal and external

Is it possible to expose two Swagger UIs, let's say public and internal with NSwag? I've tried with .AddSwaggerDocument(ConfigurePublic); + .AddSwaggerDocument(ConfigureInternal); but this generates two versions that are selectable from a single UI…
tymtam
  • 31,798
  • 8
  • 86
  • 126
0
votes
1 answer

I want scope checkbox checked by default swagger Nswag

Here is Swagger/OpenAPI definition: services.AddOpenApiDocument(document => { document.DocumentProcessors.Add(new SecurityDefinitionAppender("Bearer", Enumerable.Empty(), new OpenApiSecurityScheme …
user584018
  • 10,186
  • 15
  • 74
  • 160
0
votes
1 answer

Show different example values in NSwag when DTO is re-used in the schema

I want to generate different example values for the same complex object, for eg: public class RequestDto { // ... public class EntityDto SomeEntity {get; set;} public class EntityDto OtherEntity {get; set;} // ... } public class…
0
votes
0 answers

Generate with nswag an openAPI document including swashbuckle custom operation filters

I'm using Swashbuckle in an ASP .NET MVC application which is configured with additional operation filters like so: GlobalConfiguration.Configuration .EnableSwagger(c => { …
Artur
  • 128
  • 10
0
votes
2 answers

what is the meaning of generate code of NSwag?

I know the nswag can show the api doc but why we should use it to generate code? Just to generate the CUDA code? Is it useful?
liang.good
  • 213
  • 3
  • 12
0
votes
1 answer

How do I configure a .NET Core 3 application to use a SPA and Swagger UI?

Problem When I attempt to load the SwaggerUI when visiting localhost:5001/swagger I receive an error in the SwaggerUI that alerts me of the following: Fetch error undefined /swagger/v1/swagger.json It is also interesting to note that my .NET…
pyRabbit
  • 803
  • 1
  • 9
  • 33
0
votes
1 answer

How to dynamically change the API_BASE_URL from nswag generated typescript Angular client

I would like to dynamically change the API_BASE_URL configured in my typescript client generated by NSWAG. I would like to use the same client with one API_BASE_URL within an angular module and another API_BASE_URL within another Angular module. Is…
vcial
  • 257
  • 1
  • 3
  • 13
0
votes
1 answer

NSwag: a clear steps and clean sample on how to use class extensions in NSwag studio

There are not clear documentation on how to extend the auto-generated TS file using NSwag. I mean the extension methods with a protector access modifier here a discussion with the NSwag's owner: https://github.com/RicoSuter/NSwag/issues/1012 but…
0
votes
1 answer

NSwag : How can i suppress controllers ASP.NET Core

ASP.NEt Core 3.1 I would like to suppress one certain controller. Therefore i tried use the DocumentProcessor, but without success. public class DocumentProcessor : IDocumentProcessor I have no access to this specific controller. So i need a…
ahorak
  • 123
  • 8
0
votes
1 answer

Conditional OperationProcessor in NSwag

I try to add conditionally an OperationProcessor in NSwag. For example, the DefaultApiValueOperationProcessor should only be added/enabled when we are in a development environment (env.IsDevelopment) Unfortunately I can't retrieve…
Julian
  • 33,915
  • 22
  • 119
  • 174
0
votes
1 answer

NSwag CSharpClientGenerator custom request headers for bearer token

Is it possible to add custom request headers using the NSwag CSharpClientGenerator? I have this method generated from one of my API endpoints that takes in some parameters including a bearerToken. Notice in my HttpRequestMessageBody I have this hard…
greg
  • 1,118
  • 1
  • 20
  • 40
0
votes
1 answer

How to do code generation with NSwag after Startup?

I want to have generated typescript files. In Startup.cs there is following code. Configure: services.AddSwaggerDocument(); ConfigureServices: app.UseOpenApi(); app.UseSwaggerUi3(); So I need something like this: var document =…
FoxPro
  • 2,054
  • 4
  • 11
  • 34
0
votes
0 answers

NSwag throws an error when I am trying to map swagger.json to typescript

I am attempting to use NSwag to automate my typescript client code generation. I installed the tool using npm and set up an npm script. This is the script I am running: nswag openapi2tsclient /input:https://localhost:5001/swagger/v1/swagger.json…
michael
  • 787
  • 2
  • 6
  • 12
0
votes
1 answer

NSwag generated client not sending two parameters

I have an API project using .NET Core 2.2 that includes a call with two parameters: [HttpGet(nameof(VerifyCreds))] [Route("VerifyCreds/{fName}/{lName}")] public ActionResult> VerifyCreds(string fName, string lName) { var…
ewomack
  • 607
  • 9
  • 23