-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issueStatus: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I'm working on a PC that uses Italian Culture (it-IT). The following code:
builder.Services.AddValidation();
// ...
app.MapPost("/api/range", (Input input, [Range(42.1, 89.8)] double value) =>
{
return TypedResults.Ok();
});
app.Run();
public record Input
{
[Required]
[Range(1234.56, 7891.1)]
public double Value { get; set; }
}
Produces incorrect OpenAPI schemas because it does not take regional settings into account (e.g., minimum and maximum values):
"parameters": [
{
"name": "value",
"in": "query",
"required": true,
"schema": {
"maximum": 898,
"minimum": 421,
"pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
"type": [
"number",
"string"
],
"format": "double"
}
}
"schemas": {
"Input": {
"required": [
"value"
],
"type": "object",
"properties": {
"value": {
"maximum": 78911,
"minimum": 123456,
"pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
"type": [
"number",
"string"
],
"format": "double"
}
}
}
}
In fact, the test GetOpenApiParameters_HandlesRouteParameterWithValidationAttributes fails on my Italian machine, in particular on this assert:
Line 340 in b83721c
[([Range(1234.56, 7891.1)] decimal id) => {}, (OpenApiSchema schema) => { Assert.Equal("1234.56", schema.Minimum); Assert.Equal("7891.1", schema.Maximum); }], |
Expected Behavior
Minimum and maximum values should be correctly set in the OpenAPI schema even when the culture used is different from en-US.
Steps To Reproduce
Minimal repro at https://github.com/marcominerva/RangeAttributeIssue
.NET Version
10.0.100-preview.6.25358.103
Metadata
Metadata
Assignees
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issueStatus: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi