-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds metadata to contracts #1466
Conversation
@marcingrzejszczak hi, sorry what does mean |
So in the name: add-produce
description: Operation for adding a new produce item
request:
method: POST
url: /api/v1/produce
headers:
Content-Type: application/json;charset=UTF-8
body:
name: "Kiwi"
subName: ""
quantity: 75
matchers:
headers:
- key: Content-Type
regex: "application/json.*"
body:
- path: $.quantity
type: by_regex
value: "[0-9]+"
- path: $.name
type: by_regex
predefined: only_alpha_unicode
metadata:
restdocs:
headers:
- key: Content-Type
description: "Produce endpoint expects JSON encoded request bodies"
body:
- path: $.name
description: "Name of new produce item"
- path: $.subName
description: "Sub-name of new produce item providing a more specific name for the produce item"
- path: $.quantity
description: "Number of produce item currently in stock"
response:
status: 200
body:
id: 10
name: "Kiwi"
subName: ""
quantity: 75
headers:
Content-Type: application/json;charset=UTF-8
matchers:
body:
- path: $.id
type: by_regex
value: "[0-9]+"
metadata:
restdocs:
headers:
- key: Content-Type
description: "Produce endpoint provides responses in JSON"
body:
- path: $.id
description: "Unique id of new produce item"
- path: $.name
description: "Name of new produce item"
- path: $.subName
description: "Sub-name of new produce item providing a more specific name for the produce item"
- path: $.quantity
description: "Number of produce item currently in stock" That way we'd put it into the |
It is possible, it is better to add clean documentation for it with a good example, cause we have strange String / yaml / json conversions here. metadata("""
restdocs:
headers:
- key: Content-Type
description: "Produce endpoint provides responses in JSON"
""") Thanks :) |
There's no example atm that's why we're prototyping. I've reformatted the example name: add-produce
description: Operation for adding a new produce item
request:
method: POST
url: /api/v1/produce
headers:
Content-Type: application/json;charset=UTF-8
body:
name: "Kiwi"
subName: ""
quantity: 75
matchers:
headers:
- key: Content-Type
regex: "application/json.*"
body:
- path: $.quantity
type: by_regex
value: "[0-9]+"
- path: $.name
type: by_regex
predefined: only_alpha_unicode
metadata:
restdocs:
headers:
- key: Content-Type
description: "Produce endpoint expects JSON encoded request bodies"
body:
- path: $.name
description: "Name of new produce item"
- path: $.subName
description: "Sub-name of new produce item providing a more specific name for the produce item"
- path: $.quantity
description: "Number of produce item currently in stock"
response:
status: 200
body:
id: 10
name: "Kiwi"
subName: ""
quantity: 75
headers:
Content-Type: application/json;charset=UTF-8
matchers:
body:
- path: $.id
type: by_regex
value: "[0-9]+"
metadata:
restdocs:
headers:
- key: Content-Type
description: "Produce endpoint provides responses in JSON"
body:
- path: $.id
description: "Unique id of new produce item"
- path: $.name
description: "Name of new produce item"
- path: $.subName
description: "Sub-name of new produce item providing a more specific name for the produce item"
- path: $.quantity
description: "Number of produce item currently in stock" For Groovy it would be either a similar map or just calling rest docs methods metadata("restdocs": RestDocsStaticMethods.foo().bar().baz()) |
Ah, I get it, it was YAML contract. I'm used to groovy :) Yes, it is nice so far! |
fixes #1340
wiremock
metadata mapfixes #1078 , #1406
wiremock
metadata map (unfortunately webhooks won't work due to a mismatch of versions between WireMock 2.21 (used by extension) and 2.27 (used by Spring Cloud Contract).as for #1084 we could add a metadata entry that would be of
restdocs
key and there we could apply additional work related to restdocs (wdyt @wkorando @artemptushkin )cc @Buzzardo - there is documentation changed here so once this gets merged could you please do a editing pass?