smocker-dev / smocker

Smocker is a simple and efficient HTTP mock server and proxy
https://smocker.dev
MIT License
1.16k stars 61 forks source link

application/x-www-form-urlencoded body matcher #243

Closed mknapik closed 1 year ago

mknapik commented 2 years ago

I have a use case for mocking third-party API where data is sent with POST via body in application/x-www-form-urlencoded format. It seems Smocker is pretty flexible in terms of various matchers for individual JSON keys but matchers for urlencoded params is not supported.

So far my workaround looked the following:

- request:
    method: POST
    path: "/test"
    headers:
      Content-Type: application/x-www-form-urlencoded
    body:
      matcher: ShouldEqual
      value: username=${username}&password=${password}
  response:
    status: 200
    headers:
      Content-Type: application/json
    body: >
      {
      }

However, this solutions relies on order of the params which should not be relevant.

Would you consider adding support for urlencoded body matching?

Thiht commented 2 years ago

Yep, that should be a supported feature.

We'll try to implement this asap :)

Powerrr commented 1 year ago

Hi! Is there maybe any news here?

gwleclerc commented 1 year ago

Added in 0.18.4