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

Generate API client to use in vue

I've used NSwag to generate a typescript API client, using Axios template, to be used in my vue frontend (I can add the generated client as well as the nswag config if needed). Axios has been added as dependency: "dependencies": { "axios":…
Philippe
  • 1,949
  • 4
  • 31
  • 57
0
votes
0 answers

NSwag (Command-Line OR Studio) not generating Swagger from Assembly

Problem: I wish to generate a Swagger file (Open API document) from an ASP.NET Core 2.2 Web API project (either from the solution file or Compiled assemblies). Everything is tried using the NSwag tools. Setup I've installed NSwag studio so "nswag"…
Anas S
  • 43
  • 1
  • 9
0
votes
1 answer

New version of Nswag generates incompatible data types

I have a CMD script that uses "nswag swagger2csclient" to generate a client for communicating with another API. It has worked before but once it used a newer version of Nswag things started going wrong. The code looks like this: // Controller…
0
votes
1 answer

Swashbuckle or NSwag documentation for dynamic request body

I need to document all different request models for the endpoint: public Task Post(JObject request) { ... } What options do I have besides just writing detailed comments about expected request models or creating endpoints per…
Andrei
  • 42,814
  • 35
  • 154
  • 218
0
votes
2 answers

Does strong-typing break HTTP PUT?

I'm having a trouble with updates in a Api C# Client generated with NSwag and how to use the HTTP PUT verb. Let's say I have a DTO called customer public class CustomerDTO { public int id { get; set; } public string name{ get; set; } …
Luc
  • 59
  • 7
0
votes
1 answer

Server name is incorrect with NSwag/OpenApi

We have our api hosted at: https://oursitename.com When we try opening our OpenAPI spec here: https://oursitename.com/openapi/v1/openapi.json, we see that server name specified there is incorrect one: "https://realsitename.azurewebsites.net". Some…
Dmytro Gokun
  • 405
  • 3
  • 24
0
votes
2 answers

NSwag for Asp.Net Web Api 2 show security in swagger gui

We have installed nswag in our project and it works fine so far. But all our functions are secured with an api-key. when I take a look on the demo page from swagger, I can see the lock a the end of each api call where I need to Authorize (I think…
squadwuschel
  • 3,328
  • 3
  • 34
  • 45
0
votes
1 answer

Swagger thinks the payload is coming from "query"

I have an aspnet core project with a simple REST API. NSwag is used as Swagger tool, and it works based on the decorations I put on the models and controller's methods: [Route("api/v2/")] public class JobCollectionsControllerV2 : Controller { …
johni
  • 5,342
  • 6
  • 42
  • 70
0
votes
0 answers

Is it possible to output a cs client file to another project?

I am trying to use NSwag to generate a client during the build of the project. It does so, but it puts the cs file in a folder directly in the webapi project I am getting the spec file out of. I want to output it out to another project. Won't making…
0
votes
1 answer

Swagger generated using NSwag not found for ASP.Net Core Service Fabric service when using httpsys with altered listener path

When we used NSwag with default settings for ASP.Net Core Service Fabric service, which had altered HttpSys listener url (added path suffix), the generated swagger.json and UI where not found/accessible. Setting url path for HttpSys…
marek_lani
  • 3,895
  • 4
  • 29
  • 50
0
votes
1 answer

Add custom request headers in NSwag

Some of my controllers require custom headers to be defined in a valid request. The only way I know so far to add headers is to explicitly define a [FromHeader(Name = "X-Custom-Data")] parameter in my action methods. I however have a middleware…
TorbenJ
  • 4,462
  • 11
  • 47
  • 84
0
votes
1 answer

Can NSwag invoke a custom Swagger generator?

Is there a way to specify a custom ISwaggerGenerator or invoke some method or program to produce the output swagger spec in the swaggerGenerator section of nswag.json? The standard fromSwagger generator seems to work with only an output path, so as…
StackOverthrow
  • 1,158
  • 11
  • 23
0
votes
1 answer

Generating response validation

Hi dear NSwag community! I'd like to extend the TS generation templates for NSwag to include validation of the response. So for example, if my (exported) DTO looks like this: export interface GetListResultOfResourceDto { Items?: ResourceDto[] |…
FabianTe
  • 516
  • 4
  • 22
0
votes
1 answer

nswag generates proxy which spoils the URL

The general idea of nswag software is amazing. The guys have totally ruined it though. I'm really now thinking of dropping it for the following reasons: overcomplicated problematic extremely poorly documented unpopular Regarding my version -…
Alex Herman
  • 2,708
  • 4
  • 32
  • 53
0
votes
1 answer

NSwag - provide additional information for the expected data in a controller action

I have a controller action that accepts data in the form of an array of objects (Complex object called ControlLinePointDto). For reasons described in my question and answer here, I read this into a JArray rather than a ControlLinePointDto[]. I do…
statler
  • 1,322
  • 2
  • 15
  • 24
1 2 3
27
28