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

Unable to add authorization to swagger api document in asp.net core

I have a asp.net core 6 project setup for multiple api versioning. However, when I open the nswager api document. The Authorize button on the right side does not display at all. I'm not sure what I'm missing. Below is my snippet code: public static…
Hoang Minh
  • 1,066
  • 2
  • 21
  • 40
0
votes
0 answers

Add Context body to nSwagStudio generate methods

I have the following api post method in a controller [HttpPost("Upload/Csv")] public async Task> UploadCsv() i use nSwagStudio to generate the methods for my blazor app which create an interface with the following method ///…
0
votes
0 answers

Version number in code generated by NSwag is detected by Git as a difference

I have a client class which is generated in Visual Studio 2019 using the Unchase OpenAPI (Swagger) Coonected Service Extension. The generated client class is given the following attributes. [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.10.7.0…
Jun1s
  • 51
  • 5
0
votes
0 answers

NSwag.CodeGeneration.TypeScript marks all reference types as nullable

I'm using NSwag.CodeGeneration.TypeScript in a .NET 6 application to generate a file with types for the front end in TypeScript. This is my code: var settings = new TypeScriptClientGeneratorSettings { GenerateClientClasses =…
Maurice Klimek
  • 930
  • 5
  • 13
  • 48
0
votes
0 answers

Result abstraction cannot be mapped correctly using NSwagStudio when generating typeScript client proxy

I'm using this Result abstraction to send an appropriate message with my data. For example, I'm using the following code to return the JWT together with a welcome message: public async Task> GetTokenAsync(TokenRequest…
0
votes
0 answers

Axios CancelToken through NSwag Generated Client Interface?

I am using NSwagStudio to generate a client class for a React app. I'm generating a client interface so that I can use test data to provide to the application through another implementation of the client. I would like to start implementing…
sfaust
  • 2,089
  • 28
  • 54
0
votes
1 answer

InjectionToken in NSwag generated files not injecting

Real quick, using nswag to generate a client service, trying to configure the api base url by using injection token. The generated code by nswag: All of these ideally should NOT be touched, otherwise you will lose the changes on every regeneration.…
Yogurtu
  • 2,656
  • 3
  • 23
  • 23
0
votes
0 answers

NSwag multipart form generate Blob

Endpoint which accepts multipart form data look valid in Swagger, and accepts form data from a client. However the typescript client generated by NSwag is not usable. The generated method only accept Blob. uploadDoc(content:Blob): Observable I…
0
votes
0 answers

Multiple body parameters found in operation 'documentsPUT'

Can anyone tell me why i'm getting error when trying to consume this openAPI schema https://sandbox.penneo.com/api/docs/swagger.json which I need in my .NET 6 or .NET 7 C# project. When I in Visual Studio 2022 use Connected Service to consume I get…
Bala
  • 21
  • 4
0
votes
0 answers

How to expose the underlying HttpClient in the API client generated using Visual Studio Connected Services and NSwag

I have generated an API client using Visual Studio Connected Services. It has all the methods that are available on the Swagger, but I need to make a custom call using the same base address. I do not want to create an additional HttpClient and would…
elm
  • 339
  • 5
  • 12
0
votes
1 answer

Nullable DataTime/DateTimeOffset parameter in Header causing error in NSwag generated client

We have an Open Api specification that we are using to generate an Http client using the NSwag openapi2csclient from MSBuild.
FinneVirta
  • 374
  • 1
  • 4
  • 14
0
votes
0 answers

NSwag MSBuild Specification Generation in .Net Framework 4.8

I have a project built in .Net Framework 4.8, i have implemented NSwag, decorated postprocess with basic stuff, such as title, version, description, added few extensions, and made it serve openapi-v3 version(since it serves swagger 2.0 by default…
Nesani
  • 1
  • 1
0
votes
0 answers

Validation of request data defined by OpenApi specification in TypeScript

I have OpenApi/nswag specification json file, which contains validation/format metadata (only important part is shown): { "x-generator": "NSwag v13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))", "swagger": "2.0", "paths": { …
Evgeny Gorbovoy
  • 765
  • 3
  • 20
0
votes
0 answers

Code generation whit NSwag for a project written in French: Bad client name

I am working on a project written in French. The classes are named in French. I want to use code generation for a C# client. [Route("[controller]s")] public class EtablissementControleur : ControllerBase { ... } My api route is good and my…
0
votes
1 answer

NSwag generated Angular client post file to .net core backend

I want to do this very simple thing: post a file to my controller. I have a .net core 6.0 backend. My frontend API client is generated by NSwag my controller looks like this: (the model contains an 'IFormFile' called file.) …
Kasper Sølvstrøm
  • 270
  • 1
  • 2
  • 22