apideck-libraries / portman

Port OpenAPI Specs to Postman Collections, inject test suite and run via Newman 👨🏽‍🚀
http://getportman.com/
Apache License 2.0
639 stars 59 forks source link

Unable to reference the properties defined in form-data in overwriteRequestBody #662

Open Arrow2dknee opened 1 month ago

Arrow2dknee commented 1 month ago

Hello there.

I have a POST endpoint called /vehicles which has been implemented as multipart/form-data and accepts 3 properties, namely-

In postman, this request would look like below screenshot- image

and, the OpenAPI spec is as follows- { "/v1/vehicles": { "post": { "operationId": "VehicleController_addVehicle", "parameters": [], "requestBody": { "required": true, "description": "Vehicle data", "content": { "multipart/form-data": { "schema": { "$ref": "#/components/schemas/AddVehicleDto" } } } }, "responses": { "200": { "description": "Vehicles added successfully" }, "401": { "description": "Authorization is required", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UnauthorizedExceptionDto" } } } }, "404": { "description": "Vehicle type does not exists", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NotFoundExceptionDto" } } } }, "500": { "description": "Internal Server Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UnknownExceptionDto" } } } } }, "tags": [ "Vehicles" ], "security": [ { "bearer": [] } ] } } } Alternatively, please find the above spec in jsonblob

My overwrites.yml code looks like below: `- openApiOperation: "POST::/v1/vehicles" overwriteRequestBody:

In the overwrites.yml file, I'm referencing the form-data props as key: 'files', key: 'vehicleType' etc But, I don't think this works as expected.

When running the tests locally, got the following error from API- image

Could you please guide me what I'm doing incorrectly.

thim81 commented 1 month ago

hi @Arrow2dknee

The jsonblob mentions $ref elements, but the actual $ref values are missing. Would it be possible to share the endpoint and related components/schemas, that way we can try to reproduce your setup and investigate your issue.

Arrow2dknee commented 1 month ago

Hi @thim81,

The API looks like below: image

AddVehicleDto (from $ref) looks like below image

The form-data needs the below required information- 'files' - a json file 'vehicleType' - string representation of a mongo id 'release' - string representation of a mongo id

I have written my overwrites for this endpoint as below: image

Let me know if this helps.

Arrow2dknee commented 1 month ago

Hi @thim81 , Could you please have a look into my comment above?

Arrow2dknee commented 1 month ago

Hi @thim81 , I'm still having this issue. Could you please let me know if you have all the information to assist me with this issue? If not, let me know what you need.

thim81 commented 1 month ago

hi @Arrow2dknee

Would it be possible to share the OpenAPI endpoint as YAML or JSON, only that endpoint?