It’s common to develop a new API or add functionality to an existing one by writing code. A code-led approach is about producing the desired behavior by writing code in a local or shared development environment.Once you agree upon the API’s shape and behavior, you produce a machine-readable contract. This contract will then be used to provide a set of tests that will automate the validation of assertions stakeholders make throughout the development process.
-
Workspaces - Even when an API is developed in a code-led manner, you should set up a dedicated workspace to provide a single place to find all work.
-
Annotations - Use programming language annotations to add the necessary metadata to the code behind an API in order to generate a machine readable contract.
-
CI/CD Pipeline - Use your CI/CD pipeline to turn annotations into machine- readable contracts.Translating your code into a contract allows you to power documentation, using the forward motion of AIIs to produce the contracts you will need to define them.
-
Contract - Produce a machine-readable contract for your API, leveraging code and your existing software development life cycle to create the contract needed to govern each API.
-
Document - Generate human-readable documentation from an APIs contract, ensuring that is accurate and up-to-date.
-
Feedback - Gather feedback on the design of an API, tapping into existing channels to understand what consumers and other stakeholders need from it.
-
Iterate - Update the code base based upon feedback, adding capabilities, and building and updating the machine-readable contract, which then updates elements downstream.
-
Tests - Produce contract tests for APIs. Add tests to your CI/CD pipeline to ensure that each API continues to reflect the agreed-upon contract, with no surprises in production.
Code annotations are the key that links a code-led approach with some of the benefits of design-led. API design still exists when writing code, and annotations help express the design as machine-readable API contracts. Using the existing software development life cycle to produce API contracts, you can t power documentation, testing, and other benefits often associated with a design-led approach. Code-led lets you build upon the existing skills of teams, translating their work to produce some of the benefits design-led champions like to showcase.