-
Notifications
You must be signed in to change notification settings - Fork 27
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
Updating our handling of JSON Schema to be compliant against allowEmptyValue #110
Conversation
} | ||
|
||
function getOtherParams(pathOperation, oas) { | ||
let pathParameters = pathOperation.parameters || []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed this from pathParameters
to operationParameters
because in the context of what this is doing, it's building up an array of every parameter on the option; not an array of every path parameter on the operation.
i spent a good amount of time trying to hunt down some weird edge cases when writing tests before realizing this is what was going on 🙃
@rafegoldberg @gratcliff This is good for review.. Happy to go over it with you if you've got questions about WTF this is. |
@jon It's hard to review this without knowing exactly what the outcome of the data transformation should look like. There don't appear to be any glaring issues - data checks are present so nothing should fail. There is a lot of iteration and the recursion scares me a tad, but overall I think that's a necessity with the schemas you're trying to process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like Gabe said, a bit tricky to logic through some of this data transformation stuff. But yeah, code looks solid; I'm good on this!
This resolves some issues with how we're constructing JSON Schema with regard to empty
default
properties.Previously when an empty
default
was added into a data schema, a bug would cascade up into@readme/api-explorer
and our usage of@readme/oas-to-har
and we'd create an API HAR of a payload consisting of empty strings.Instead now, if a
default
evaluates to an empty string, andallowEmptyValue: true
is present on that property, we'll let the empty value through, otherwise it'll get tossed.allowEmptyValue
. See https://swagger.io/specification/#parameterObject for details on the property.