We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If you have a double property with an example in one of your models, the swagger.json is invalid JSON if the culture is not en-US
class MyDto { /// <summary> /// Test /// </summary> /// <example>84420.01</example> public double? Test { get; set; } }
JSON output :
"test": { "type": "number", "description": "Test", "format": "double", "nullable": true, "example": 84420,01 },
In order for it to work, I needed this hack :
public static void GenerateSwaggerFile(this IHost app, string url, string apiVersion = "v1", string outputJsonFilePath = "swagger.json") { //super hacky way in order to generate correct examples for double //see https://stackoverflow.com/q/76810078/1545567 CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; var swaggerProvider = app.Services.GetRequiredService<ISwaggerProvider>(); var swagger = swaggerProvider.GetSwagger(apiVersion); swagger.Servers = new[] { new OpenApiServer { Url = url } }; using var streamWriter = File.CreateText(outputJsonFilePath); var writer = new OpenApiJsonWriter(streamWriter); swagger.SerializeAsV3(writer); }
The text was updated successfully, but these errors were encountered:
This is fixed in DotSwashbuckle, can you test using it please. https://github.com/Havunen/DotSwashbuckle https://www.nuget.org/packages/DotSwashbuckle.AspNetCore
Sorry, something went wrong.
Proposed fix in #2726
Successfully merging a pull request may close this issue.
If you have a double property with an example in one of your models, the swagger.json is invalid JSON if the culture is not en-US
JSON output :
In order for it to work, I needed this hack :
The text was updated successfully, but these errors were encountered: