Azure / Azure/azure-functions-openapi-extension

Range Attribute too strictly applied

Open
#491 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

I have a model like this:
```csharp
TokenRequestModel {
//Shortened for brevity
[Range(0, int.MaxValue)]
public int? TokenExpirationInMinutes { get; set; }
}
```
When I open the Swagger UI and try to post values like `-1` or `null`, no loading animation is shown and not any request is made. Furthermore, no indication is shown (visually or in the console) that the request could not be made.

I do not think this is expected behaviour, as when I annotate an emailaddress with `[EmailAddress]` I am still able to post wrongly formatted email addresses.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the TokenRequestModel example in Swagger UI with -1, null, and an invalid email address, then trace where Range validation prevents the request. No file or test is named in the issue; done means the behavior is consistent with the intended validation rules and gives visible feedback when a request cannot be made.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.