Skip to content
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

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

Open
Arrow2dknee opened this issue Oct 7, 2024 · 5 comments

Comments

@Arrow2dknee
Copy link

Arrow2dknee commented Oct 7, 2024

Hello there.

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

  • files (json file uploaded by client)
  • vehicleType (alphanumeric string)
  • release (alphanumeric string)

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: - key: 'files' value: 'files:tests/portman/create-vehicle.json' - key: 'vehicleType' value: '6703abea1c0324d0e17d5afb' - key: 'release' value: '6703abf51c0324d0e17d5b28' overwriteRequestHeaders: - key: Content-Type remove: true

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
Copy link
Collaborator

thim81 commented Oct 7, 2024

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
Copy link
Author

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
Copy link
Author

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

@Arrow2dknee
Copy link
Author

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
Copy link
Collaborator

thim81 commented Oct 15, 2024

hi @Arrow2dknee

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants