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.
nswag
459
questions
0
votes
0
answers
8
views
Why does NSwag's Typescript Client assert `null as any`?
Template code: https://github.com/RicoSuter/NSwag/blob/master/src/NSwag.CodeGeneration.TypeScript/Templates/Client.ProcessResponse.Return.liquid
Generated code looks something like:
protected ...
0
votes
0
answers
25
views
How to Display Dictionary<string, string> Properly in Swagger UI using NSwag
I am using NSwag to generate Swagger documentation for my API. One of my API endpoints uses a Dictionary<string, string>, but in the Swagger UI, it is displayed as a generic object. Instead of a ...
0
votes
0
answers
23
views
NSwag auto generate client: Generates return object type function wrong
Just I'm trying to generate HttpClient generated file by NSwag from my API controller.
I have this marked row in my API controller:
But it generates here wrong return type:
I'm expecting return ...
0
votes
0
answers
11
views
Can NSwag generate a DayJS duration from a C# TimeSpan?
Im changing from moment to dayjs in my projects and running into a little issue. A C# TimeSpan was generated as a moment.Duration before now as a dayjs.Dayjs (by setting "dateTimeType": &...
2
votes
0
answers
56
views
How NSwag handles anyOf
I have a .net class library which uses NSwag to generate client code from an OpenApi spec, a portion of which is as follows:
"postal_code": {
"anyOf": [
{
&...
0
votes
0
answers
15
views
the difference between Appserver and Web.Host in nswag
I have 2 functions .
one is in the AppServer , like
[HttpPost]
functionA(ObnectDto dto)...
one is in the web.host ,likes
[HttpPost]
functionB(ObnectDto dto)...
the 2 functions all have the attribute ...
0
votes
1
answer
131
views
.NET 8 Minimal API - Finding Endpoints using NSwag that use AddEndpointFilter
I am using currently using AddEndpointFilter for my endpoint using MinimalAPI
app.MapGet("/{Id}", Method).AddEndpointFilter<HeaderFilter>()
Using NSwag's OperationProcessor, I want to ...
1
vote
0
answers
35
views
NSwag WrapResponseMethods parameter format
When adding an OpenAPI service reference I can't get the WrapResponseMethods to work. From https://github.com/RicoSuter/NSwag/blob/6b49eefa4048cecfd41ba0d7484bd1f25543d22d/src/NSwag.Commands/Commands/...
0
votes
0
answers
47
views
How to Include CustomJson Converters while generating api clients using Nswag?
I have following DTO class in api project which uses RangeConverter.
public class DTO
{
public string Name { get; set; }
[JsonConverter(typeof(RangeConverter))]
public ...
0
votes
0
answers
29
views
Can't apply custom settings when generating client via `nswag openapi2csclient` command
I have the following powershell script where I use nswag openapi2csclient to generate a client. And I'm trying disable settings useBaseUrl and generateBaseUrlProperty
$namespace = "MyNamespace&...
0
votes
1
answer
133
views
REST + GraphQL Api in NET 8 does not work properly on IIS
I have a minimal API that includes both REST and GraphQL endpoints, built with .NET 8, NSwag 14, and HotChocolate 13.9. Everything works wonderfully when debugging in Visual Studio, but issues arise ...
1
vote
1
answer
129
views
Nswag CSharp Client generator marking strings as Required
I have a .Net 8.0 WebAPI project which Im using NSwag to produce a c# SDK APIClient class so that I can interact with it from another project.
NSwag is marking all strings with this attribute
[...
1
vote
2
answers
249
views
ASP.NET Core 8 Minimal API - Swagger with jwt
The authorization button is displayed, but if I paste a valid JWT token I got:
Error: Unauthorized
content-length: 0
date: Sun,12 May 2024 21:37:28 GMT
server: Kestrel
www-authenticate: Bearer
I don'...
0
votes
0
answers
28
views
c# NSwag.AspNetCore discriminator not shown for single object
1 am using c# NSwag.AspNetCore. And I have a polymorphic model. The definition is:
components:
schemas:
TestModel:
type: object
discriminator:
propertyName: $type
...
0
votes
1
answer
545
views
NSwag start the .NET 8 API Project in Command="$(NSwagExe_Net80) run NSwag.json /variables:Configuration=$(Configuration)"
In the Dotnet API project, recently we are upgradign .NET version from 6 to 8.
In the new version of the application, in the nswag.json file
"documentGenerator" engine is changed from "...