when 2 operations have the same input schema definitions, the requests in the PDF output are not displayed
Hi, RapiPdf is very good, and would really fit my simple need, but I have one showstopper.
Just imagine a sligthly modified petstore example with just an added operation, POST /store/backOrder, the same as POST /store/order, with the same input, but a supposedly different business logic. (#/definitions/Order) petstore_plus_backorder.txt
...
"/store/order": {
"post": {
"tags": [
"store"
],
"summary": "Place an order for a pet",
"description": "",
"operationId": "placeOrder",
"produces": [
"application/xml",
"application/json"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "order placed for purchasing the pet",
"required": true,
"schema": {
"$ref": "#/definitions/Order"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Order"
}
},
"400": {
"description": "Invalid Order"
}
}
}
},
"/store/backorder": {
"post": {
"tags": [
"store"
],
"summary": "Place an back order for a pet",
"description": "",
"operationId": "placeBackOrder",
"produces": [
"application/xml",
"application/json"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "order placed for purchasing the pet",
"required": true,
"schema": {
"$ref": "#/definitions/Order"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Order"
}
},
"400": {
"description": "Invalid Order"
}
}
}
},
...
if you do that, and this would happen a lot in real life, reusing the same schema for input on different operations,
then in the PDF, the two request sections content just disappear, only leaving the REQUEST title right before RESPONSE

To retrieve the desired output, the only solution I found is to duplicate the Order definition with another name. which beats the purpose of openApi definitions reusability.
In our case, we may have for instance a definition called UserTokenInput, used in 15 different operations, this would mean we'd have to duplicate it from UserTokenInput1 to UserTokenInput15 ... and amend each operation accordingly.
RapiDoc does not have the same issue. It displays the 2 requests content correctly.
Can this be solved easily ?
Best regards, David
+1 -- I believe I see this same issue with responses, as well as requests.
Still facing it. Anyone looking into this issue?
I have fixed it manually for now. You can add the following code at line 132 in src/spec-parser.js
The issue is: in such cases it needs to pick the schema from requestBodies which it is not doing. Check swagger2openapi for more info
if (fullPath.requestBody && fullPath.requestBody.$ref) { const ref = fullPath.requestBody.$ref.split('/'); const refName = ref[ref.length - 1]; const refObj = openApiSpec.components.requestBodies[refName]; if (refObj) { fullPath.requestBody = refObj; } }