Request Matching: bodyPatterns is a list not a dict
i-fimafeng opened this issue · comments
i-fimafeng commented
Issue:
the API to match request with bodyPatterns is expecting a array of dict not directly a dict.
bodyPatterns Array of object Request body patterns to match against in the : { "": "" } form from http://wiremock.org/docs/api/#tag/Stub-Mappings/paths/~1__admin~1mappings/post
Whereas class MappingRequest(BaseAbstractEntity)
in models.py
define it as a dict
body_patterns = JsonProperty('bodyPatterns',
klass=dict)`
Step to reproduce
Try matching request body
mapping = Mapping(
priority=100,
request=MappingRequest(
method=HttpMethods.GET,
url='/hello',
bodyPatterns={"matchesXPath": "//world"}
),
response=MappingResponse(
status=200,
body='hi'
),
persistent=False,
)
create an error 500 in wiremock when trying to match.
Solution
Adding a list around dictionary works fine.
mapping = Mapping(
priority=100,
request=MappingRequest(
method=HttpMethods.GET,
url='/hello',
bodyPatterns=[{"matchesXPath": "//world"}]
),
response=MappingResponse(
status=200,
body='hi'
),
persistent=False,
)
but defining bodyPatterns
as JsonProperty
of klass dict
is misleading.
Cody Lee commented
Cody Lee commented
fixed and released in 2.0.0