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

Validate array min and max items when using "Try it out" functionality #6327

Closed
reder9 opened this issue Aug 19, 2020 · 1 comment · Fixed by #6878
Closed

Validate array min and max items when using "Try it out" functionality #6327

reder9 opened this issue Aug 19, 2020 · 1 comment · Fixed by #6878

Comments

@reder9
Copy link

reder9 commented Aug 19, 2020

Content & configuration

Swagger/OpenAPI definition:

        "parameters": [
         {
           "name": "non_empty_list",
           "in": "query",
           "description": "Just a list of ints",
           "required": true,
           "schema": {
             "type": "array",
             "minItems": 1,
             "items": {
              "type": "integer",
              "format": "int32"
              }
            }
         }
       ],

Is your feature request related to a problem?

Kind of, I'm not sure if this is a bug or a feature request but for my project we have the concept of lists and nonempty lists and I was hoping to add some way to distinguish between the 2 on my OpenAPI spec. I saw here https://swagger.io/docs/specification/data-models/data-types/ the minItems property and the statement that Without minItems, an empty array is considered valid. So I was hoping to be able to set minItems to 1 then if you tried not having that it would fail (much like when you have a required parameter and don't set a value for it)

Describe the solution you'd like

I would like to see that if your array doesn't meet the minimum or maximum items requirements that a failure message is displayed in the UI, or at least some indicator that it didn't work.

Additional context

Example of what happens when you don't fulfill the "required" property and run Execute. I was thinking something like that but saying "The array expects a minimum of X elements but no more than Y and Z were provided" something along those lines.
Screen Shot 2020-08-19 at 11 26 32 AM

@reder9
Copy link
Author

reder9 commented Aug 19, 2020

One other thing I'll mention is that this also seems to be the case with the uniqueItems property for arrays that it isn't getting validated as well. Not sure if that warrants another ticket or not but thought I would mention it because I feel that should also do some validation.

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

Successfully merging a pull request may close this issue.

2 participants