463 questions
Advice
0
votes
0
replies
23
views
Is it possible to generate string fields and const classes from nullable open enums in an OpenAPI spec?
I'm trying to generate a C# client from the OpenRouter OpenAPI spec:
https://github.com/OpenRouterTeam/typescript-sdk/blob/main/.speakeasy/in.openapi.yaml
Among other things there are some enums ...
0
votes
1
answer
40
views
How to configure multiple security schemes in ASP.NET Core Swagger with NSwag API spec
I have an ASP.NET Core 8 Web API with a Swagger page using Nswag + OpenAPI3. I also have an OAuth2 security implementation which is working great. Thanks to AspNetCoreOperationSecurityScopeProcessor ...
0
votes
1
answer
194
views
Avoid blocking on NSwag generated client
The code generated by NSwag allows the consumer to pass a CancellationToken, which it uses on the call to HttpClient.SendAsync, but it doesn't use on the downstream call to response.Content....
0
votes
0
answers
35
views
Swagger - how to preserve enum integer value while serializing with JsonStringEnumConverter
API, Program.cs:
builder.Services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
API, MyEnum.cs:
public enum ...
0
votes
0
answers
46
views
NSwag SwaggerUI suggests "string" as input for a byte array member
We have an API using NSwag and its SwaggerUI. Our API includes enpoints with byte array members:
class SomeData
{
public int someField { get; set; } //Muse be a property otherwise it's not ...
0
votes
1
answer
58
views
Exclude NSwag Swagger UI from ASP.NET Core Authentication
I'm using NSwag library and AzureAD for authentication and want to exclude the swagger UI from asp.net core authentication entirely, similar to using the AllowAnonymous attribute on the controller.
...
0
votes
1
answer
121
views
Apply authorization filter to Swagger UI endpoint (NSwag)
I have an ASP.NET Core 8.0 MVC application to which I'm adding NSwag.
The web application uses a custom authorization filter to apply custom authorization logic to most of the MVC controllers (but not ...
0
votes
0
answers
449
views
Status 204 issue with scaffolded OpenAPI method using NSwag in Visual Studio
We're generating a C# implementation of a self-developed Web API using Visual Studio's default "Add … Connected service" method. This API returns status 204, if the request was syntactically ...
0
votes
1
answer
641
views
Generating valid schema for generic type in OpenAPI v3 with NSwag
I am trying to generate a valid OpenApiDocument using NSwag but fail when it comes to generate schemas the way they should be. I am currently adding schemas for my types globally like this:
var type = ...
2
votes
1
answer
877
views
NSwag produces incorrect output for IFromFile in Minimal API when file parameter is wrapped in model class
I’m working on a .NET 8 Minimal API (web) project and using NSwag for generating Swagger documentation. I have an endpoint that accepts a file upload, and the file parameter is wrapped inside a model ...
0
votes
0
answers
149
views
How the Open API controller/service is added?
I am using NSwag to generate the controller code for a c# Open API service
Then, in Program.cs, it is just a simple code from the sample project
var builder = WebApplication.CreateBuilder(args);
// ...
1
vote
1
answer
188
views
Technology for generating a list of schemas in OpenApi 3.0 yaml format based on C# types
I need to generate type schemas in OpenApi yaml format. I am considering any technology that can be used to manually create an OpenApi 3.0 document without generation based on ASP.NET Core controllers....
0
votes
0
answers
60
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 ...
3
votes
0
answers
582
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": [
{
&...
2
votes
0
answers
239
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/...
1
vote
1
answer
470
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
[...
0
votes
1
answer
4k
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 "...
0
votes
0
answers
275
views
How to Generate C# Client Code with Calculated Properties Using NSwag from OpenAPI Spec
I'm currently using NSwag to generate a C# client from an OpenAPI specification.
I have a particular case where I want a property in my C# model to be calculated based on other properties, similar to ...
0
votes
1
answer
459
views
Make Swagger UI display input endpoint parameters data types
When i use Swagger UI in my ASP .NET Core project, i can't see input parameters data types.
I use endpoint like this:
/// <summary>
/// SomeSummary
/// </summary>
/// <param name="...
1
vote
1
answer
1k
views
Newtonsoft.Json.JsonSerializationException: Error setting value to 'SelectedSwaggerGeneratorRaw' on 'NSwag.Commands.NSwagDocument'
I am upgrading the .NET 6.0 project to .NET 8.0.
After upgrading the
.NET version to 8.0,
NSwag.MSBuild package version:
<PackageReference Include="NSwag.MSBuild" Version="14.0.4&...
1
vote
0
answers
157
views
NSwag fails on endpoints accepting a DateTime
Adding this endpoint:
[HttpGet("[action]")] public async ValueTask Test(DateOnly d) { }
Causes NSwag to fail with this error:
Severity Code Description Project File Line Suppression ...
0
votes
0
answers
125
views
Swagger generating request string[] headers incorrectly?
Im having an interesting issue in the generated swagger document concerning headers.
In this case the header permissions is a string[]
In the request object received in the controller instead of the ...
3
votes
0
answers
220
views
nswag appends a number suffix to action name for same action names
I have a ASP.NET Core 6.0 and Angular 13 & TypeScript 4.5 project.
I use Swagger and NSwag for create TypeScript clients.
My swagger.json like as below:
{
"openapi": "3.0.1",...
1
vote
2
answers
1k
views
How to change the error response body for ASP.NET Core Web API and NSwag
I am using .NET Core 8.0, Newtonsoft json and NSwag to generate a Web API server. We have a custom json error body response we use for errors.
That works fine when we generate the error.
However, if ...
2
votes
0
answers
188
views
Is there a way to generate PascalCase properties using nswag studio?
Is there a way to generate C# clients with PascalCase properties using NSWagStudio or the nswag command line?