Giter Club home page Giter Club logo

Comments (9)

tomakehurst avatar tomakehurst commented on May 22, 2024

I like this idea. I'd been thinking a while back about how to be a bit more expressive in specifying query parameters, and I think this could be the right way.

I'm happy to add this to my backlog, or accept a pull request of you feel like having a go at adding it yourself.

from wiremock.

christianbalzer avatar christianbalzer commented on May 22, 2024

Is this now scheduled for a future version?
And is there an example of how to do this currently?

from wiremock.

tomakehurst avatar tomakehurst commented on May 22, 2024

It's on the list, although I don't have any idea when I'll get to it as I haven't been able to commit much time to it recently.

The query string is included when evaluating a URL regex (with urlMatching(...)) so it's possible to match on query params this way.

from wiremock.

ricoli avatar ricoli commented on May 22, 2024

Hello! I wonder if this feature proposal has had any love recently? This would be really useful as at the moment we can't do "urlPattern": "/something?param=[a-z]+" - it seems only full url match works with query string. Am I correct?

from wiremock.

tomakehurst avatar tomakehurst commented on May 22, 2024

I've been up to my eyeballs in client work over the last couple of months, so I've had no time at all for WireMock stuff. Expecting a break soon where I can catch up a bit.

I'm surprised the example you've given isn't working. Can you give an example of a URL you'd expect to match but doesn't?

from wiremock.

ricoli avatar ricoli commented on May 22, 2024

Understandable, and let me congratulate you on your fine work with this tool :)
The example I was talking about is this one:
URL: /something?param=value
Mapping:

{
    "request": {
        "method": "GET",
        "urlPattern": "/something?param=[a-z]+"
    },
    "response": {
        "status": 200,
        "body": "something",
        "headers": {
            "Content-Type": "test/plain"
        }
    }
}

This request gets a 404...

In order for this request to match, the mapping would currently have to be exact:

{
    "request": {
        "method": "GET",
        "url": "/something?param=value"
    },
    "response": {
        "status": 200,
        "body": "something",
        "headers": {
            "Content-Type": "test/plain"
        }
    }
}

from wiremock.

tomakehurst avatar tomakehurst commented on May 22, 2024

The problem is that the ? in the urlPattern is unescaped. Try this:
"urlPattern": "/something\\?param=[a-z]+"

from wiremock.

ricoli avatar ricoli commented on May 22, 2024

Ah indeed that would probably be it, silly me!

from wiremock.

tomakehurst avatar tomakehurst commented on May 22, 2024

Query param matching added in 1.52

from wiremock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.