Reputation: 863
From the docs on externalizing the examples https://specmatic.in/documentation/contract_tests.html it says Scenario “Update Employee Success” - We have not added response examples, however Specmatic will still validate the response against the schema in our OpenAPI Specification
Does this imply that it's possible to provide response examples in the Scenario Outline table in the spec file? Right now it only appears to be able to process that the status was 200
Then status 200 and then verifies that the response is in the format specified in the openapi yaml file but there doesn't appear to be a way to link an row in the Examples section to a specific expected response
Is there a Github online which houses the employees example in the docs? Specifically the employee.spec & employee-without-examples.yaml?
Upvotes: 0
Views: 274
Reputation: 356
Co-founder, CTO of Specmatic here.
Does this imply that it's possible to provide response examples in the Scenario Outline table in the spec file? Right now it only appears to be able to process that the status was 200
You will notice that we have only provided the request body and not provided a response body under examples in the Scenario “Update Employee Success”. This is because Specmatic Contract Test validates the response that it receives from the System Under Test / Application against the response schema in the OpenAPI specification. While adding an inline example within an OpenAPI specification still acts as a documentation aid, in the use-case that you have highlighted, where we are moving examples to a Gherkin spec file to avoid bloating the OpenAPI, adding response data to the example row adds little value. Which is why we have not added the same.
That said we will also update the documentation to clarify the above.
Then status 200 and then verifies that the response is in the format specified in the openapi yaml file but there doesn't appear to be a way to link an row in the Examples section to a specific expected response
As you may have already noticed each scenario in Gherkin file is linked to the OpenAPI specification base on a combination of method, path and status code. However in case of contract test the response values that need to be validated against specification are coming from Application's response there is no need to provide the same in the example row.
Is there a Github online which houses the employees example in the docs? Specifically the employee.spec & employee-without-examples.yaml?
We do not have this hosted anywhere, however you can copy paste the content from the gists in the documentation to create these files.
Hope this helps.
Upvotes: 0