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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

NSwag C# Client Not Properly Generating Azure.ETag

I have the following ASP.NET Core 7 Web API controller in C# that saves an attachment to Azure Blob Storage: [MapToApiVersion(Constants.ApiVersions.V1)] [HttpPost] [ProducesResponseType(typeof(...
kingua's user avatar
  • 61
0 votes
1 answer
29 views

NSwag Generated C# Client with IFormFile

I am using NSwag to generate a C# client from a dotnet 7 Web API that is consumed by a Blazor WASM application. I am having trouble getting a Post with an IFormFile to upload an attachment with the ...
kingua's user avatar
  • 61
0 votes
0 answers
11 views

Generating Inheritance classes using "x-ms-discriminator-value" value

I am currently using NSwag to generate a API Client using the following in the csproj file. <ItemGroup> <OpenApiReference Include="OpenAPIs\FormRecognizer.json" CodeGenerator=&...
Jonathan Stanton's user avatar
0 votes
1 answer
21 views

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 ...
Nourelayne Salah eddine's user avatar
1 vote
0 answers
58 views

NSwag include null values for properties

In an OpenAPI document I have specified for a property that the value may also be null. Here is an example of a property: "PersonBirthdate": { "type": "...
user3644868's user avatar
0 votes
1 answer
31 views

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 ...
cdarrigo's user avatar
  • 964
0 votes
0 answers
12 views

{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,...
Valentin Vadász's user avatar
0 votes
0 answers
10 views

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 ...
Mani's user avatar
  • 105
0 votes
0 answers
11 views

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. /// <summary> /// ...
Chuilu Meng's user avatar
0 votes
1 answer
77 views

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 $...
dvalentine314's user avatar
0 votes
1 answer
87 views

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\...
M_Idrees's user avatar
  • 2,080
0 votes
0 answers
36 views

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 ...
Stefan B.'s user avatar
0 votes
0 answers
26 views

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 ...
Yi Chun Lin's user avatar
0 votes
2 answers
42 views

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 ...
João Fernandes's user avatar
0 votes
0 answers
24 views

How to remove Extra Required attribute added by NSwag

I have some code like below: namespace BSN.Commons.Responses { // // Summary: // Generic response type for command/query services to return the results. [DataContract] public ...
sorosh_sabz's user avatar
  • 2,356
0 votes
0 answers
112 views

NSwag.MSBuild is timing out when added as target to a .csproj target

I'm teaching myself the basics of NSwag right now. With the goal to standardize & automate my company's API Clients. During this I found the NSwag.MSBuild which seemed perfect for my desires to ...
Curtis's user avatar
  • 1
0 votes
0 answers
41 views

Nswag: Is there a way to generate only non-primitives and nullable primitives as nullable?

I'm looking for a way to have nswag generate a C# client for me that generates nullables for nullable primitives and all non-primitives, but not for non-nullable primitives. Say I have a C# object ...
Charlie Delune's user avatar
1 vote
0 answers
118 views

Add service reference using OpenAPI and VS2022

I have an OpenAPI-file with the following three endpoints: { "openapi": "3.0.1", "info": { "version": "1.0" }, "paths": { &...
MakePeaceGreatAgain's user avatar
0 votes
1 answer
123 views

How to generate TypeScript client using NSwag in form of named properties?

We generate TypeScript client from swagger interface using NSwag. The generated client looks like following: client.EndPointFoo(arg1, arg2, arg3, ...) We deal with issues that NSWag change order of ...
Tomas Kubes's user avatar
  • 23.9k
1 vote
1 answer
147 views

KnownType equivalent for discriminator on Interfaces in NSwag

When we need to tell NSwag and the generated OpenAPI 3.0 document that an abstract class should be converted to some concrete type on the client side, I use [KnownType] with a discriminator and that ...
DavGarcia's user avatar
  • 18.6k
0 votes
1 answer
392 views

SDK Resolver Error: Could not resolve "Microsoft.NET.Sdk.Web"

I am getting the following errors on NSwag Studio since a week. I had done a VS 2022 update recently and the current version is 17.5.5. I tried reverting to the previous version but it still doesn't ...
codredd's user avatar
  • 21
1 vote
1 answer
347 views

good practice for adding auth in asp.net (swagger/open api)

I have an API in asp .net 6, and I need to add basic auth. i don't see any default schemas that I can use instead of writing my own auth handler. Because it is just a very simple thing user needs to ...
Abdelrahman Hazem's user avatar
0 votes
1 answer
43 views

ModelState validation in auto-generated controllers

I want to return 400 Bad request when ModelState.IsValid is false, i.e., when a string is not mapped correctly to an appropriate enum. (For example when calling GET v1/abc/def/gamma for API GET v1/abc/...
12oClock's user avatar
0 votes
1 answer
528 views

Nswag studio is unable to handle a JSON body with an array

I am using NSwag Studio to generate a C# client for an external Swagger API that I need to interact with. One of the properties on an API call that I am attempting to execute is a typed array. From ...
R. Reinders's user avatar
0 votes
1 answer
161 views

config.json and using values in app.module.ts providers

Currently, we are building our angular (v15) application once for each environment we deploy to, since we are using the environment.ts files to handle variable transforms. I would like to get us to a ...
Delubear's user avatar
0 votes
0 answers
39 views

Nswag IOperationProccessor alternative at runtime

I have created a method that implements IOperationProcessor looking for to hide operations depending of the permissions of a user. In my implementation with Nswag , the IOperationProcessor method is ...
Nando's user avatar
  • 11
0 votes
0 answers
35 views

Generate typescript @summary from [annotation] in dotnet

I have a set of DTOs, that can be either submitted or received by the client in an api call. The way, that we synchronize between client<-> server DTOs is using NSwag, which generates a client....
alx's user avatar
  • 1
0 votes
1 answer
197 views

Sending date from angular frontend to aspnetcore backend - timezone troubles

I have a problem sending dates via a NSwag generated typescript client to an aspnetcore webapi. The generated code is: getExchangeRate(from: string, to: string, date: Date): Observable<...
Dominic Shaw's user avatar
1 vote
1 answer
286 views

How to tell NSwag C# Client generator to use our DTOs instead of generating new ones?

We currently have over 100 DTOs already well-designed in a separate assembly and span multiple namespaces. How can we instruct the NSwag C# client generator to utilize our existing DTO library instead ...
Mohammad Nikravan's user avatar
0 votes
0 answers
209 views

OpenAPI generator fails to type hint a file from NSwag

I have a backend service written in .NET Core and I use NSwag to generate a Swagger client. My client app, which is written in TypeScript, uses this Swagger to generate code for the requests. This ...
anthino12's user avatar
  • 800
1 vote
1 answer
280 views

How can I generate at compile-time a separate OpenAPI Swagger.json file for each Controller in my ASP.NET project?

Our ASP.NET Core web application has an ever-growing list of Controllers. At build-time of the project, I want to programmatically generate an individual separate swagger.json file for each Controller....
Vyrotek's user avatar
  • 5,356
1 vote
0 answers
295 views

nswag net 6 auto generated c# client

I have an .net 6 api that already uses swagger to generate the swagger UI. I am attempting to create a C# client that lives in a class library. The structure will look something like this. ...
MakeThePainStop's user avatar
0 votes
1 answer
175 views

Cannot send file content to an API with Post method code generated with nswag from swagger.json

Exception occured on line : (after PrepareRequest) var response_ = await client_.SendAsync(request_, System.Net.Http.HttpRequestException: 'Error while copying content to a stream.' IOException: ...
Julien Duprat's user avatar
0 votes
1 answer
288 views

Generating a TypeScript client for React components embedded in an ASP.NET MVC web app

The question: is it possible to automatically generate a TypeScript client that defines data transfer between a React component and an ASP.NET MVC controller? The context is: we have a TypeScript ...
Dave's user avatar
  • 455
0 votes
1 answer
526 views

How to generate the openapi.json with nswag

I am using nswag to generate the swagger. However the openapi json file is only in memory, you can only access it by starting the application and navigate to the link swagger/v1/swagger.json. I want ...
Phuong Duyen Huynh Ngoc's user avatar
0 votes
1 answer
405 views

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 ...
Hoang Minh's user avatar
  • 1,076
0 votes
0 answers
30 views

Add Context body to nSwagStudio generate methods

I have the following api post method in a controller [HttpPost("Upload/Csv")] public async Task<ActionResult<string>> UploadCsv() i use nSwagStudio to generate the methods for ...
Adam Kangas's user avatar
1 vote
0 answers
123 views

NSwag, csharp client generation SingleClientFromOperationId in c#

I'm trying to use NSwag in C# to generate a CSharp based httpClient from an OpenAPI spec. The generated HttpClient has some issues which I know why are caused but I cannot seem to find anything in the ...
user avatar
0 votes
0 answers
56 views

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....
Jun1s's user avatar
  • 51
2 votes
1 answer
940 views

Nswag adds null check for nullable/optional parameters

I have basically same issue as this (details here on Github) but with C# client - [FromForm] SomeObject x on controller has some nullable (optional) parameters and generated client generated by Nswag ...
nighthawk's user avatar
  • 773
2 votes
1 answer
376 views

How to generate interface with default property with nswag?

Is this possible to generate typescript interface with nswag that will contain the default property value? i.e. from this: public enum TempType { Good = 1, Bad = 2 } public class Item { [...
Michal Sobanski's user avatar
0 votes
0 answers
188 views

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 { ...
Maurice Klimek's user avatar
0 votes
0 answers
25 views

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<...
Majid Shahabfar's user avatar
0 votes
0 answers
119 views

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 ...
sfaust's user avatar
  • 2,089
2 votes
0 answers
636 views

Is there a way for get NSwag Swagger to generate a client that can consume IAsyncEnumerable endpoint?

I have an endpoint that returns an IAsyncEnumerable [HttpPost("GetByDates")] [ProducesResponseType(typeof(IAsyncEnumerable<DayModel>), StatusCodes.Status200OK)] public async ...
Olaf Dlugosz's user avatar
0 votes
1 answer
95 views

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 ...
Yogurtu's user avatar
  • 2,676
0 votes
0 answers
141 views

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 ...
gabor.sari's user avatar
0 votes
0 answers
120 views

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 ...
Bala's user avatar
  • 21
0 votes
0 answers
135 views

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 ...
elm's user avatar
  • 339
0 votes
1 answer
201 views

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. <Target Name="NSwag" BeforeTargets="BeforeBuild">...
FinneVirta's user avatar

1
2 3 4 5
9