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

CSharpClientGeneratorSettings generates methods with the same name

I am using CSharpClientGenerator to generate client from json schema. Unfortunately, the methods in the client are named the same (ReadAsync(), ListAsync() etc...). public NSwagGenerator( Client config) { this.config = config; …
0
votes
0 answers

NSWAG Generated code including property called System conflicting with namespace

I have a 3rd party open API spec that I have no control over. I am generating a c# client to consume this service using nswag as part of a build. The open API spec has an attribute in one of the response models which is called System as an int. When…
DShorty
  • 582
  • 1
  • 6
  • 14
0
votes
1 answer

NSwag - How to hide base URL , Version , Scheme from swagger UI

I am using .NET Core WebAPI (Nswag) I wanted to hide below items from swagger UI. Is that possible? 'Select Definition' and dropdown (Top right corner) BaseURL and Swagger.json link Schemes and dropdown. Highlighted in below screenshot.
Sathish
  • 159
  • 1
  • 4
  • 18
0
votes
1 answer

NSWAG C# Client doesn't handle 401 / Challenge by trigger a refresh of a token

The proxy generated by NSWAG for C# when calling an API is correctly getting a 401 when the token has expired. Is it possible to have it handle refreshing the token, or should be handled higher up the chain in my APP ? I am using MSAL
underwater
  • 191
  • 1
  • 11
0
votes
0 answers

Custom Typescript Date property toJSON serialisation using NSwag

We are using NSwag to generate a TypeScript Client from our .NET API swagger.json. Our API allows for Date inputs from users. Consider this example dto from the API: public class CreateCustomDatesRequestDto { public DateTime…
Dave
  • 457
  • 4
  • 15
0
votes
1 answer

How to get default parameters in C# client generated through NSwag Studio?

I have this controller endpoint in .NET Core 6. I am using Swagger and NSwag Studio (latest version v13.17.0.0) to generate C# client : [HttpGet("GetAllMinimalCalculationDtoOfMaterialByLoggedinUser/{isExistingBuildingCalculation:bool?}", Name =…
0
votes
1 answer

NSwagStudio Generated C# Client Offsets Dates

I am using NSwagStudio to generate a C# client and in general it's working great. However, I just discovered that it's not recognizing the timezone properly in date strings. I am getting an auth token back from the API with an expiration. That…
sfaust
  • 2,089
  • 28
  • 54
0
votes
1 answer

How can I create API client library in .NET Core project

We have created a new API project using .NET Core 6 and create some API controllers. For that, how can we create an API client library for this project to consume the API?
0
votes
1 answer

C# OpenApi Nswag Client Generation Complex Class is empty

I am trying to create a Client with the help of the latest versions of nswag and .net6. Many class schemas are empty if they are more complex. Something that was working in the older versions. This is one of the classes: public class ObjectDetail :…
Andre Fritzsche
  • 126
  • 2
  • 11
0
votes
0 answers

Why string with datetime is string for .net framework but DateTime for .net core?

I'm using client's Swagger YAML file to generate models for one API where one property is a string type(ISO 8601) in swagger filevalidUntil: type: string and c# props is public string ValidUntil { get; set; } which were binding string data…
DigguDg
  • 19
  • 1
  • 10
0
votes
0 answers

Swagger Generation using OneOf for Inheritance

I am trying to use NSwag to generate a swagger document for my REST API. My response object contains a property that is an abstract class. I would like the schema to use oneOf for the child classes instead. For example my current output looks like…
SA3709
  • 192
  • 2
  • 11
0
votes
1 answer

Context menu missing in Visual Studio 2022

The project that I'm working on uses the Visual Studio (2022) extension 'Unchase OpenAPI (Swagger) Connected Services' to generate a C# controller. My colleague and I have both followed a tutorial on Medium to setup this extension, and we have both…
SimonAx
  • 1,176
  • 1
  • 8
  • 32
0
votes
1 answer

nSwag Client: Is there a better/easier approach to affect PropertyNameCaseInsensitive?

We are attempting to integrate System.Text.Json into our REST API and rest clients, previously using Newtonsoft. We are using nswag CSharpClientGenerator.GenerateFile to generate our REST API clients via code (not nSwag Studio). Because of the…
Tim Bassett
  • 1,325
  • 1
  • 12
  • 23
0
votes
1 answer

Validate Requests in NSwag generated Client

I have a .NET 6 Webclient and REST Contract, that is generated from a YAML with NSwag. The contract contains some validation properties. Is there any way to validate my request on the client side? I don't want to write the validation code by…
Benjamin Ifland
  • 137
  • 1
  • 10
0
votes
1 answer

NSwag autogenerated client does not show default values

I have an api with Swagger enabled. In one of the endpoints, I have a request with some values set as default. [DefaultValue("test value")] public string? Description { get; set; } This looks fine in the Swagger page for the api. The default value…
MortenGR
  • 803
  • 1
  • 8
  • 22