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
6
votes
0 answers

how to set nswag swagger2tsclient fetch options like credentials: "include"?

Here's the commandline I use to generate my API calls: nswag swagger2tsclient /input:swagger.json /output:./gen/index.ts /ExtensionCode:./base/extension.ts /ClientBaseClass:BaseClient /UseGetBaseUrlMethod:true…
Jie Hu
  • 539
  • 1
  • 5
  • 16
6
votes
1 answer

Is it possible to use Swagger with AspNetCore Odata?

Yesterday I searched solution how to use swagger on Core Odata, I tried few libraries but with no success, it seams that currently it's not fully supported.
5
votes
2 answers

MSB3037 openapi2csclient exited with code -1

I used Visual Studio Add-Service-Reference to add a service that uses the OpenAPI Specification. I input the swagger URL and generated the code. The .csproj indicates that the service is configured. However when I try to build I get an error. The…
Kirsten
  • 15,730
  • 41
  • 179
  • 318
5
votes
0 answers

Using OpenApiReference, how to configure code generator options using a .nswag json options file (or any alternative)

Context I've added a connected service to my .NET 6 project and using NSwagCSharp code generator to generate the client. (In my previous project I used NSwagStudio) I discovered that in the .csproj file there is a possibility to add…
g.pickardou
  • 32,346
  • 36
  • 123
  • 268
5
votes
2 answers

Swagger auto generated file issue with _observableOf(null) in angular 12?

So i'm using swagger and Nswag for a very long time, I can see the auto generated methods used to generate a line like this to exit as default value: return _observableOf(null); ...And now with the same nswag json file, it…
Yogurtu
  • 2,656
  • 3
  • 23
  • 23
5
votes
2 answers

Client From NSwag CSharpClientGenerator Cannot Deserialize String

We have a Swagger.json output by using AddOpenApiDocument (see below). A snippet from the swagger as below shows it returns a 200 response type of application/json. The schema part (which I am not too familiar with) shows "type": "string". When we…
Tim Bassett
  • 1,325
  • 1
  • 12
  • 23
5
votes
2 answers

Customizing auto generated Swagger definitions

I have swagger setup so that it generates the open Api Specification & Swagger Ui on project startup using NSwag based on the controllers in my WebApi. I would like to enhance the swagger Ui to include A summary/description for each…
5
votes
1 answer

How to order/sort paths in NSwag swagger.json by controller name

I am using NSwag to generate swagger for my .NET Core api and everything works great, except the fact that paths are rendered in order that reflection seems to pickup Controllers from project. So if I do have hierarchy - some controllers at root…
nikib3ro
  • 20,366
  • 24
  • 120
  • 181
5
votes
1 answer

nswag studio generate model classes into separate files

I've been using Autorest in the past and it automatically creates interfaces and separates the models into separate files, which appears to be cleaner. I just switched over to Nswag Studio lately and couldn't find the option to separate files. Is…
Noob
  • 247
  • 1
  • 3
  • 12
5
votes
1 answer

Make properties in NSwag generated client nullable

I get this object specification in (OpenApi 3.0.1) from a vendor: "ExampleTO" : { "codeValidFrom" : { "type" : "string", "format" : "date" } } NSwag generates this property in a C# client (correctly, I…
TvdH
  • 1,088
  • 14
  • 29
5
votes
2 answers

NSwag generates multiple functions with the same name when using OpenApi 3.0 JSON file

I am trying to generate the client code in both .NET Core and TypeScript using NSwag CLI: nswag run options.nswag This works correctly for various Swagger 2.0 JSON files, but generates multiple functions with the exact same name for an OpenApi 3.0…
Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
5
votes
3 answers

How to add custom headers in NSwag document using C# .NET CORE?

I am in need of adding custom headers, but cannot figure it out. I am trying to utilize the new services.AddOpenApiDocument() instead of the services.AddSwaggerDocument(). I want to add these custom headers on my whole API not just a single method…
JVIH
  • 103
  • 1
  • 1
  • 8
5
votes
1 answer

How to Authorize Swagger to use MS Graph API

We are building a Web API wrapper for MS Graph API. I want to use Swagger to test my APIs. But I can't get the configuration right. I keep getting Bad Request and no other clue. I can't install Fiddler or other tools on this corporate laptop to…
jokab
  • 671
  • 7
  • 14
5
votes
0 answers

NSwag (Swagger) creates swagger file with case sensitivity causing inconsistent parameter names

I have an asp.net core project which uses NSwag as its Swagger tooling. The issue I am having is as follows: I have a Dto class describing the Collection entity: # namespace SchedulerApi.Entities { public class JobCollectionDtoV2 { …
johni
  • 5,342
  • 6
  • 42
  • 70
5
votes
3 answers

How do I specify the "scheme" element using NSwag and C#?

I'm using ASP.NET Core and NSwag to host and describe a new web service hosted in IIS with Windows Authentication. Locally I run the web service using https, but when I deploy to a test environment the web service sits behind a load balancer with…
phunque
  • 321
  • 3
  • 13
1 2
3
27 28