-
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
fix: optional empty validation #7003
fix: optional empty validation #7003
Conversation
I decided to refactor the validation condition to more readable state. I think this is even more readable then the comment before Signed-off-by: mathis-m <mathis.michel@outlook.de>
internal logic does send null to validation in case of empty parameter input. Signed-off-by: mathis-m <mathis.michel@outlook.de>
@mathis-m PR merged! Thanks for the contribution! |
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 I am trying this in https://editor.swagger.io : openapi: 3.0.3
info:
title: Test
version: 1.0.0
paths:
/test:
get:
parameters:
- name: names
in: query
required: false
schema:
type: array
minItems: 1
items:
type: string
responses:
200:
description: OK I would like to be able to test omitting the 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? |
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?). |
@dferretti you are right when there is no value provided and the param is optional there should not be any error. 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. |
Awesome thank you! |
Description
internal logic does send null to validation in case of empty parameter input. This should be included in the validation, This was introduced with:
5c4dfc2 Mahtis Michel 02/03/2021 09:29 PM feat: enhance parameter validation (#6878)
I decided to refactor the validation condition to more readable state.
I think this is even more readable then the comment before.
Motivation and Context
Fixes #6998
How Has This Been Tested?
Screenshots (if appropriate):
Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests