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

JSON payloads #38

Open
artsyca opened this issue Nov 8, 2017 · 6 comments · May be fixed by #84
Open

JSON payloads #38

artsyca opened this issue Nov 8, 2017 · 6 comments · May be fixed by #84

Comments

@artsyca
Copy link

artsyca commented Nov 8, 2017

When posting JSON in the body, the filename matcher attempts to match the entire body of the payload as the filename.

This has some repercussions on windows as many characters are invalid:

Reading from mocks/POST--{"data":{"index":0,"max":25},"sortBy":["name"]}.mock file: Not matched

I wonder if there are any alternative ways to match responses to requests?

@joshmorel
Copy link

This would add a bit of complexity, but looking at the code base I could imagine the following would be possible to enable this use case. I believe this would benefit Linux/Mac as well since the file names for this scenario could be pretty unwieldy and plus the json could be re-used for something else (e.g. a test).

Use a new special character -- '@' after the method which is legal within a file name for all file systems as far as I know. The part between the '@' and 'mock' within the same directory would be the a JSON file with the payload.

|--path/to/file
|--|[email protected]
|--|--payload.json

Contents of payload.json

{
    "data": {
        "index" : 0,
        "max": 25
   },
   "sortBy": ["name"]
}

Would be willing to take a stab as this library is pretty cool and potentially quite useful, but at the same time this is gap is a real limitation.

@odino
Copy link
Contributor

odino commented Mar 11, 2018

@joshmorel feel free to have a crack at it! :)

@odino
Copy link
Contributor

odino commented Apr 29, 2018

@artsyca let us know if this works on win (can't test it at the moment) -- if so, we should merge it :)

Cheers!

@skirep
Copy link

skirep commented Feb 12, 2019

I'm trying it on Windows, and it doesn't work. That's correct ? I need to do that on linux ? I want to use the external file.

@birdmod
Copy link

birdmod commented Jul 30, 2019

Hello, can I have some info on this issue. Is this going to be supported ? I saw that the pull request of @joshmorel (#44) was not merged and the whole item closed for inactivity. Is the plan to adapt his work as a new pull request ? Or is there another way of implementing this ?

@odino
Copy link
Contributor

odino commented Aug 1, 2019

Hi @birdmod no plans yet, but we'd be happy to review any PR that comes this way 😄

@HerrPfister HerrPfister linked a pull request Dec 6, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants