-
Notifications
You must be signed in to change notification settings - Fork 9k
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
empty optional array with validation constraints is considered invalid #7111
Comments
Actually I may be off on what I'm talking about anyways - I was initially reading this older PR #6878, but poking through this PR I do see some null/required checking going on. Maybe editor.swagger.io is not running this code yet (is there an easy way to see what version it is running?). Originally posted by @dferretti in #7003 (comment) |
@dferretti had a look at how it is handled for type: string minLength: openapi: 3.0.3
info:
title: Test
version: 1.0.0
paths:
/test:
get:
parameters:
- name: names
in: query
required: false
schema:
type: string
minLength: 2
responses:
200:
description: OK It allows optional or minLength of 2 both is valid. |
Yes, open the developer console, and type |
I know I'm late to the party, but I think this is relevant to this PR. I believe you can have a non-required string array param in the query, with
minItems: 1
to represent "either don't pass it at all, or if you do it must include at least 1 item". Well, I think so anyway..I know you can have a non-required, non-nullable parameter meaning "either don't provide it, or provide a non-null value, but never provide
x: null
". So I believe you can additionally constrain the array withminItems: 1
IIRC.I am trying this in https://editor.swagger.io :
I would like to be able to test omitting the
names
parameter by not providing any elements, but swagger-ui tells me I must provide at least 1 value.Should these minItems validation checks include whether or not the param is required? Or am I way off here and the spec doesn't allow that?
Originally posted by @dferretti in #7003 (comment)
The text was updated successfully, but these errors were encountered: