Question

For systems that are built on top of diverse tech stacks, including both static and dynamic types languages, what is in practice some ways to have the API contracts published and enforced?
Some wiki documentation would just stale over time so I was wondering what are various approaches used in industry for this?

Was it helpful?

Solution

Two main ways to do this:

  1. Write compatibility test suite that calls the API and verifies that the implementation conforms with the properties required by the API contract. Ideally, this should be an automated test so that the test is repeatable and consistent, but in some cases you can write a certification test that integrators need to run through before they are allowed to connect to production system.
  2. Write a schema file (e.g. XSD, JSON Schema) that implementations can run against their implementing. In many cases, clients can use schema files to automatically generate client SDK, and servers can use the schema files to generate implementation stubs. But schemas is useful even if you don't auto-generated from it; most schema languages have validators that you can run example documents against the schema to check if the document matches the schema.
Licensed under: CC-BY-SA with attribution
scroll top