GithubHelp home page GithubHelp logo

Comments (5)

tomakehurst avatar tomakehurst commented on July 19, 2024

Could you give me some more detail as to why you need this?

I've got some ideas about how to improve body specifications that may help you if implemented, so I'd be interested to know what pain points you're hitting.

Thanks,
Tom

from wiremock.

martins1930 avatar martins1930 commented on July 19, 2024

Hi,

I think that is very usefull have a posibility to configure the bodyPatterns in a external file when you have a large body in XML.

For example if i have a mapping like this:

{
    "request": {
        "method": "POST",
        "url": "/product",
        "bodyPatterns": [
            { "matches": "<product><name>Ball</name><manufacturer>A</manufacturer><price>.*</price><vendors_assigned><vendor>1</vendor><vendor>2</vendor><vendor>3</vendor></vendors_assigned></product>" }
        ]
    },
    "response": {
            "status": 200,
            "bodyFileName": "path/to/ballResponse.xml"
    }
}

I think that is better to configure a mapping in this way:

{
    "request": {
        "method": "POST",
        "url": "/product",
        "bodyPatterns": [
            { "matchesFileName": "path/to/ballRequest.xml" }
        ]
    },
    "response": {
            "status": 200,
            "bodyFileName": "path/to/ballResponse.xml"
    }
}

where the ballRequest.xml have the content of the first mapping.

Thanks and greetings,
Martin.

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

OK...I have mixed feelings about this idea.

My personal view is that it's desirable not to make your stub specs any more specific than necessary as this tends to make your tests brittle.

However, I realise that regexes are a bit of a blunt instrument in this context, so I've been thinking for a while about adding support for body matching on JSONPath and XPath.

Something like:

{
    "request": {
        "method": "POST",
        "url": "/product",
        "bodyPatterns": [
            { "matchesXPath": "/product[name='ball']" },
            { "matchesXPath": "/product[manufacturer='A']" }
        ]
    },
    "response": {
            "status": 200,
            "bodyFileName": "path/to/ballResponse.xml"
    }
}

Do you think this would help?

from wiremock.

martins1930 avatar martins1930 commented on July 19, 2024

Hi,

I think that would be great !!

It is very helpful to have the option of XPath matching.

Thanks,
Martín.

from wiremock.

tomakehurst avatar tomakehurst commented on July 19, 2024

OK, I'll bump that up the to-do list in that case. Thanks for the feedback.

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.