-
Notifications
You must be signed in to change notification settings - Fork 50
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stubbing "multipart-form-data" request with part array #690
Comments
Thanks for reporting this @aeoncl. |
Hi guys, i've started working on this. i'll submit a PR in the coming days for you to review |
Hi @aeoncl, really appreciate the initiative. |
@aeoncl Thank you for your patience. The reason we were taking time on this PR is to make sure we also understood the http RFC around this. And it does look like the expected behaviour in your bug description is valid as per this section in RFC 7578. We are now reviewing your PR in this regard. cc @jaydeepk |
Description
Hi 馃榿, here's the issue:
In a multipart-form-data, you can have an array of parts by specifing the same partname multiple times.
Here is how it looks in the OpenApi definition (pdfFiles):
We expect this to be an array of pdfFiles:
![image](https://private-user-images.githubusercontent.com/48886723/257212299-7108c02c-b43b-4acc-96f8-84b7b039ed8d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgzMzY2NzEsIm5iZiI6MTcxODMzNjM3MSwicGF0aCI6Ii80ODg4NjcyMy8yNTcyMTIyOTktNzEwOGMwMmMtYjQzYi00YWNjLTk2ZjgtODRiN2IwMzllZDhkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE0VDAzMzkzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQyNjkwY2I1MjllYWI5ZmEwMTM1OWNhMTE5YTE0NWZjOWYxMmNlYTk4MTYyNzM4OWM0NWYwZjUzZDEwMThlZGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.PfLYINfhsogHsvrt9UAvF-_Mju4yUnoG-BcoQA-qXJM)
If i send this request to the Specmatic Stub, i get the following error:
This happens because Specmatic thinks a multipart part of type array should contain an array, and not be one:
Internally this is interpreted as a ListPattern which matches only if the value is an array.
Snippet from ListPattern.kt
![image](https://private-user-images.githubusercontent.com/48886723/257209419-32ce9159-1d26-4729-bcdc-a9d1e106e52a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgzMzY2NzEsIm5iZiI6MTcxODMzNjM3MSwicGF0aCI6Ii80ODg4NjcyMy8yNTcyMDk0MTktMzJjZTkxNTktMWQyNi00NzI5LWJjZGMtYTlkMWUxMDZlNTJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE0VDAzMzkzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYxZjkyMjhhYWIzZDE3ZDdkZTEwMzdmZGRmYTU0ZTlmZjI0OTQ0NjBiMzVhYmM4YjBiOTJkY2ZlZTlkZjI1MjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Dx6x0NIimwEMLYpaYZ7O1j7o0Mlf21dFl3xZL7JDnyM)
If i change my part value to an array, it works, but that's not the behaviour i expected:
![image](https://private-user-images.githubusercontent.com/48886723/257212484-95c03747-454b-4779-b2d8-67b3a5994172.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgzMzY2NzEsIm5iZiI6MTcxODMzNjM3MSwicGF0aCI6Ii80ODg4NjcyMy8yNTcyMTI0ODQtOTVjMDM3NDctNDU0Yi00Nzc5LWIyZDgtNjdiM2E1OTk0MTcyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE0VDAzMzkzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFlMWM5NTg2ZDg0M2I5Mzk1MDZhZGEyMzI4MmE4ZmYyMDE2MzEyYmEyNjVhYTc1Zjg0MGE5NWEzZTEyODhkYWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.wyalduiUlnG1qacO1Uq776oa-6tteMrV8NcAoTTE_hE)
Steps to reproduce
Expected behavior
I expect to receive a 200 OK generated response
System Information:
Additional context
To fix it, we'll need to change the way Specmatic interprets "type: array" on multipart parts. Changing the meaning from "contains a json array" to "expect to have the same part multiple times"
The text was updated successfully, but these errors were encountered: