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

Is there a way to generate generic method with nswag?

Im using nswag with a angular2 typescript application and would like to return a generic type or 'any' in typescript from the WebAPI: public async Task GetSomeInput(SomeInput input) { if (input == "Car") { var result =…
gog
  • 11,788
  • 23
  • 67
  • 129
1
vote
1 answer

NSwagStudio generating broken client code (duplicate enum values). What am I doing wrong?

I'm trying to generate a c# client from an AspNetCore Web API using NSwagStudio. The generated code contains a set of enums that, based on the attributes decorating them, are apparently flags for Json serialization - I can't locate where any of them…
Lamont
  • 41
  • 3
1
vote
1 answer

Configuration to not wrapping results with Observable.of in TypeScript / Angular

I´m using NSwagStudio (toolchain v10.1.6309.31527) and generating a TypeScript Client for Version 2.0 and template=angular. Is there any way to configure results to not be wrapped with like return Observable.of(result200);? I just want it like in…
1
vote
1 answer

Can't load .Net Core Web API Assembly in NSwagStudio

I seem to have a problem loading .Net Core Web API assembly in NSwagStudio. I have a reference package (NuGet) for 'Microsoft.AspNetCore.Mvc (1.1.2)' in my project but this seems to break the load process on NSwagStudio. See this example: I am…
Erick Boshoff
  • 1,443
  • 2
  • 18
  • 30
1
vote
1 answer

Swagger to generate definition for custom Restful API (C#.NET)

I'm trying to use swagger for my RESTful api (.net and c#). It's a custom restful api (not ASP.NET Web API nor a web application). public interface IEmployee { [CustomSecurity(Session.Required)] EmployeeResponse GetEmployee(EmployeeRequest…
user1527762
  • 927
  • 4
  • 13
  • 29
0
votes
1 answer

ASP.Net Core 6 - ValueKind Property is added during the deserialization of a request body

hope you doing great ! I am working currently on a bff (Back for frontend) project with ASP.Net Core, that consumes an external api. For simplicity purposes, we used **Nswag **which is a tool to generate code from an api specification compliant to…
0
votes
1 answer

Calling versioned endpoints via accept header using SwaggerUI and nSwag

I've got an ASP.NET Core 6.0 web app that uses versioned endpoints. I've selected to use the MediaTypeApiVersionReader, which means the api version is passed in the accept header of the request. I'm using nSwag v13.19.0 for the Swagger pipeline,…
cdarrigo
  • 964
  • 1
  • 8
  • 26
0
votes
0 answers

{controller} placeholder doesn't work when generating TypeScript client with NSwag

I want to generate a TypeScript client from an openApi specification. I'm using NSwagStudio to create the config file. I leave the default {controller}Client value, but the placeholder returns nothing, the class name will be just Client. What could…
0
votes
0 answers

NSwag C# client generater ignores Enum attribute

I have an enum which is decorated with an attribute as below, but the generated client by Nswag does not has the attribute as expected. Is there a way to configure that the attribute is present in the generated client. [Obfuscation(Exclude = true,…
Mani
  • 105
  • 1
  • 1
  • 8
0
votes
0 answers

Swashbuckle.AspNetCore generated api file isn't not satisfy the OAS 3 spec

I use the Swashbuckle.AspNetCore @ v6.5.0 version to generate a OAS file. while I find that the file generate is not satisfy the OAS spec. Here is my c# code. /// /// Inheritance and Polymorphism ///
0
votes
1 answer

nswag is generating invallid swagger.json with $type properties

I am using NSwag to generate and serve an OpenAPI document. for the most part it generates just fine. however, sometimes when my coworker tries to serve the page locally, the JSON created includes $type properties (but only sometimes). Here is an…
dvalentine314
  • 60
  • 1
  • 7
0
votes
1 answer

VS 2022 - Rebuild Error - NSwag - openapi2csclient - exited with code -1

I am using Visual Studio 2022 (Version 17.6.5), the nuget package for NSwag.ApiDescription.Client (version 13.19.0). When try to Rebuild, its is getting this error: The command ""x\packages_rep\nswag.msbuild\13.0.5\build\../tools/Win/NSwag.exe"…
M_Idrees
  • 2,080
  • 2
  • 23
  • 53
0
votes
0 answers

NswagStudio: C#-Client causes the error messages that some functions aren't available in the context

I use NswagStudio to generate a C#-Client by the swagger.json. If I generate the C#-Client I will get always the error messages that the functions UpdateJsonSerializerSettings() and CreateHttpRequestMessageAsync() aren't available in this context. I…
Stefan B.
  • 33
  • 5
0
votes
0 answers

Restricting access to Swagger page in ASP.NET Web API 2 with NSwag

I have ASP.NET Web API 2 and have configured Swagger using NSwag. I want to restrict access to the Swagger page, expicially in the production environment. It is my intention to incorporate a login authentication page, so I tried using ActionFilters,…
0
votes
2 answers

How to add authentication to nswag documentGenerator

I have a nswag.json file with my configuration to generate c# http clients. However, the swagger url that I want to point to is protected with Http basic auth. Is it possible to add to the configuration file the necessary username and…
João Fernandes
  • 75
  • 1
  • 10