express-openapi-validator
express-openapi-validator copied to clipboard
[v >= 4.10] requestBody schema does not contain $ref anymore
Describe the bug From version 4.10, the requestBody schema loaded by OpenApiValidator has changed and does not contain the property $ref anymore. This property was used by openapi-express-generator to give a name to the requestBody automatically.
To Reproduce
print the variable request.openapi.schema.requestBody.content['application/json'].schema using version 4.9.5 and then 4.10.0
Actual behavior
Does not contain the property $ref
{
// missing $ref here
example: {
//...
},
properties: {
//...
other_object: {
// not the $ref I am looking for
'$ref': '#/components/schemas/MyRequestBody_other_object'
}
},
required: [],
type: 'object'
}
Expected behavior
Should contain the property $ref as before
{
'$ref': '#/components/schemas/MyRequestBody'
}
Examples and context
Generate any server with openapi-express-generator, then run it with version 4.9.5 of openapi-express-validator and with 4.10.0
Facing the same issue as we were using openapi generator with old version, but after switching to latest version missing $ref is causing issue. Any workaround or fix implemented?