spec-first/connexion

MockResolver: support "x-amples" in definitions

Open

#336 建立於 2016年10月31日

在 GitHub 查看
 (3 留言) (2 反應) (0 負責人)Python (4,346 star) (738 fork)batch import
enhancementhelp wanted

描述

Following #292 and #308 it would be also interesting to support the x-amples swagger extension which goes beyond response-only examples by allowing the explicit specification of request/response example pairs.

This supported extension could also be the foundation for future contract testing related features, this inter-microservices contract testing workflow could potentially look something like this:

(1) The Consumer sends a PR to the Provider's swagger.yaml by adding to the x-amples section the ones they are using and whose contract is important to be kept from an API consumer perspective

(2) The Provider accepts the PR as long as is consistent with the spec.

(2.1) Once accepted the Provider will include the validation of those x-amples during unit the tests, this means the Provider will setup the necessary test data to validate that is consistently able to fulfill and respect this contract, preventing breaking changes going without notice.

(2.2) When a breaking change is detected, the Provider should contact all the Consumers and request them to upgrade the x-amples that matches the new API and a proper transition to the new API can be negotiated without breaking them in production.

(2.3) Every time the Provider runs the unit contract tests it POST the results to a broker service (this doesn't exist yet) similar to a pact_broker but the difference is that we don't host the contracts there as we've just moved them to the swagger.yml x-amples section. This xamples_broker (to name it somehow) will act as a central point of confirmation for Consumers so they can be at peace that their contracts are actually being unit tested and not left to forgetfulness. This feature would be something like this

(3) With this x-amples support in place Consumers can now spin up a mock server out of the empowered swagger.yml file and have mocked dependencies out of the box, which takes us back to this feature request:)

貢獻者指南