-
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(oas3): fix getting initial values for request body in OpenAPI 3.x #9762
Conversation
const oneOf = schema.get("oneOf") | ||
const anyOf = schema.get("anyOf") | ||
|
||
if (oneOf || anyOf) { |
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.
Perhaps we could move handling these below this line
let initialValue = fn.getSampleSchema(schema, false, {
includeWriteOnly: true
})
So that if the parent schema has an example, we would get the initial value from it. We would need to reassign the schema, type, format and description then.
|
||
const schemaWithoutKeywords = schema.filter((v, k) => k !== "oneOf" | ||
&& k !== "anyOf" | ||
&& k !== "$$ref" |
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.
I think $$ref
should be the exception when checking if we have properties other than anyOf
or oneOf
in the schema.
Not sure if there's a better way of doing this than filtering out these properties.
I updated the code so that we won't be overwriting existing properties in the schema with the nested schema and created an issue for not getting nested schema properties: #9763 I'm wondering though, wouldn't this be solved by merging the nested schema with the parent schema? |
Changes the behaviour from only getting initial values for the parameters that have examples or have type
object
to getting initial values for every parameter. Also fixes the issues of not getting examples and correct input in the form foranyOf
andoneOf
, and of not filling initial values if they are falsy. Changes based on findings documented in #9754.Applies to request bodies with content type
application/x-www-form-urlencoded
andmultipart/...
.Before:
After: