Skip to content
New issue

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

Better Presentation of Maximum and Minimum String Length #2630

Closed
APIWriter opened this issue Dec 9, 2024 · 5 comments
Closed

Better Presentation of Maximum and Minimum String Length #2630

APIWriter opened this issue Dec 9, 2024 · 5 comments

Comments

@APIWriter
Copy link

APIWriter commented Dec 9, 2024

Describe the bug
I don't like the way minimum and maximum string lengths are presented. They are seen as an unlabeled array such a [5 .. 10]. It's not clear at one glance what the notation even refers to.
Image

Expected behavior
A more precise presentation would be to label each one explicitly:
Minimum length: 0
Maximum length: 5

Minimal reproducible OpenAPI snippet(if possible)
The coding is good, just not the rendering.

        zip_code:
          type: string
          minimum: 5
          maximum: 10
          nullable: true
          description: |
            Specifies the ZIP or postal code of the receiving destination.
          example: '91104'

Screenshots
Image

Additional context
Add any other context about the problem here.

@AlexVarchuk
Copy link
Collaborator

AlexVarchuk commented Dec 30, 2024

It looks like the same to me #2631

@APIWriter
Copy link
Author

APIWriter commented Dec 30, 2024 via email

@AlexVarchuk
Copy link
Collaborator

Sorry I put the wrong link. Updated and added comment to that #2631 (comment).
I believe these cases related to same options(minimum/maximum) and how render that field. No reason to have separate issue for that.

@jeremyfiel
Copy link

I think your interpretation of null is slightly different than what is defined in OpenAPI or JSON Schema. Optionality has nothing to do with the validation results other than when the required keyword is used.

null equates to a field with a null value

# valid
test: null

that is different than empty

# invalid
test: ""

the validation for string fields only activates when a string value is defined. empty or otherwise but not with the null value.

Based on the constraints you have [5, 10] and nullable: true

# valid
test: null

# valid
test: letters

# invalid
test: ""

# invalid
test: five

# invalid
test: areallylongstring

@APIWriter
Copy link
Author

APIWriter commented Feb 12, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants