-
Notifications
You must be signed in to change notification settings - Fork 279
Open
Description
Describe the bug
The generated OpenApi 3.1 definition of an action containing long parameter results in ["integer", "string"] type definition. This cuases issues in SwaggerUI where it fails validation for any valid integer number.
Tried with
- `Microsoft.AspNetCore.OpenApi: 10.0.1
- Swashbuckle.AspNetCore: 10.1.0
- .NET 10 runetime
OpenApi File To Reproduce
Add the OpenApi file you're using or a link to it as well as the steps to reproduce the current behavior.
Expected behavior
Validation to pass and request to be sent when displayed in SwaggerUI.
Screenshots/Code Snippets
Additional context
[HttpPut("{projectId}/active")]
public async Task<ActionResult<Project>> IsActive([Range(0, long.MaxValue)] long projectId)
{
}Issue appears whether the range is set or not.
Workaround
builder.Services.AddOpenApi(options =>
{
options.AddSchemaTransformer((schema, context, cancellationToken) =>
{
if (schema.Format == "int64" && schema.Type.HasValue)
{
schema.Type = JsonSchemaType.Integer;
}
return Task.CompletedTask;
});
}
This was the only workaround I found. It works well with both, integers and long numbers.
Metadata
Metadata
Assignees
Labels
No labels