This repository was archived by the owner on Nov 8, 2024. It is now read-only.
Normalise OpenAPI type as an array internally #598
Merged
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.
This is one of the first steps in supporting OpenAPI 3.1's type as an array. This first step normalises the type into an array internally, so that all the internal code paths in the code base use arrays.
This means that the
parseType
function in the schema parser will always return an array of strings. In this implementation that array will always be of a single item. There is code which would throw if that wasn't the case. It is not possible to enter the code path, this will be altered in the future to something along the lines of:but first, the parser needs to be able to parse the arrays, and there will be various tests for all those cases. That will come later.
One thing I will point out, is that
parseString
accepts a member element and not a string, that's because it uses the member element's key to construct the error message, this makes it hard to compose with other subparsers such asparseArray
which is why the string parsing is done inline.parseType
accepts a string element (and in the future an array of string elements if you use OpenAPI 3.1). In the past,parseType
accepted the member element with the value of a string element.