Repository navigation
Parse and validate referenced array query parameters like inline ones - #167
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An array query parameter declared under
components/parametersand used through$refwas parsed as a single value. The operation only knew the parameter's alias name (type Terms = []string), not its items, so the handler fell back toruntime.ParseString[Terms]on the first value, which returns nil for a slice without an error.The service got nil for
?term=one&term=two, and since an alias can't have aValidate()method, item constraints likemaxLengthwere never checked either. A parameter whoseschemais a$refto an array component schema was parsed the same way, though that type's ownValidate()still ran.What changes
?term=one&term=twogives["one", "two"], and an item that doesn't parse as the item type is a 400. This covers a referenced component parameter, a component parameter whose schema references an array schema, and an inline parameter that does.Validate()checks each item, since the alias has no method of its own.?term=one&term=toolongagainstmaxLength: 3is now a 400 and doesn't reach the service.Validate(), so itsminItems/maxItemsstay enforced.runtime.ParseStringstill returns the zero value for a type it can't parse. Failing on slices instead would turn every request carrying a path or header array parameter into a 400, since those values aren't split into items yet.ParameterDefinition.ArraySchemareturns the schema of the slice type a parameter is declared with, looking through a named type. The handler's query parsing uses it instead of.Schema.ArrayType, which stays unset for a parameter declared with a named array type such asTagList.Fixes #163