pact-foundation / pact-specification

Describes the pact format and verification specifications
MIT License
295 stars 28 forks source link

How to match xml elements with namespace ? #91

Open yambati-tillster opened 2 years ago

yambati-tillster commented 2 years ago
<request xmlns:ns2="http://schemas.datacontract.org/2004/07/System">
    <Options>
        <CalculateItemPrice>true</CalculateItemPrice>
    </Options>
    <Order>
        <DestinationId>1</DestinationId>
        <Discounts/>
        <FutureOrder>
            <EmailAddress>testEmail@test.com</EmailAddress>
            <PhoneNumber>000(000)-0101</PhoneNumber>
            <PickupTime>
                <ns2:DateTime>2021-11-15T01:00:00-07:00</ns2:DateTime>
                <ns2:OffsetMinutes>0</ns2:OffsetMinutes>
            </PickupTime>
        </FutureOrder>
        <Items>
            <NewOrderItem>
                <Id>1</Id>
                <ItemId>649475714</ItemId>
                <Modifiers/>
                <Price>6.29</Price>
                <DestinationId>1</DestinationId>
            </NewOrderItem>
        </Items>
        <Name>Single Item</Name>
        <Payments>
            <NewOrderPayment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"NewExternalPayment">
                <Amount>6.80</Amount>
                <Id>2</Id>
                <TenderId>649481142</TenderId>
                <TipAmount>0</TipAmount>
            </NewOrderPayment>
        </Payments>
        <Surcharges/>
    </Order>
</request>

"matchingRules": { "body": { "$.request.Order.FutureOrder.PickupTime.{http://schemas.datacontract.org/2004/07/System}DateTime['#text']":{ "matchers": [ { "match": "regex", regex": "\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2]\\d|3[0-1])T(?:[0-1]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+|)(?:Z|(?:\\+|\\-)(?:\\d{2}):?(?:\\d{2}))" } ] } } }

This rule is currently not matching ,Is this the right way to specify the path in the case of elements with namespace. "$.request.Order.FutureOrder.PickupTime.{http://schemas.datacontract.org/2004/07/System}DateTime['#text']" could not find any examples or documentation. using pact-jvm, pactSpecification specification version: 3.0.0

yambati-tillster commented 2 years ago

I am currently blocked on this, Any updates or response for the issue is highly appreciated

uglyog commented 2 years ago

Pact-JVM repository would be a better place to raise this.

But I don't recall seeing matching rule paths with namespaces in them. It might be a bug.

yambati-tillster commented 2 years ago

Thank you! I would log the issue @ Pact-JVM