liveBook · Manning

Code-first approach

As explained in Automating API Delivery

An API development practice that implements an API in code from business requirements and generates its API definition afterward.

The code-first approach implements an API from business requirements, then generates its OpenAPI definition from the application code. That definition can drive client SDKs and API reference documentation. section 6.3

A practical code-first workflow is:

  • Implement the required API behavior and any changes that should appear in its reference documentation. section 6.3
  • Generate an OpenAPI definition from the implementation. section 6.3
  • Inspect the generated schema and examples; compare the result with the design-phase source of truth when one exists. section 6.3.2
  • Fix differences or use the definition to produce consumer-facing artifacts such as SDKs and reference documentation. section 6.3 section 6.3.2

Prototype before design commitment

A team can prototype an API in code to uncover technology constraints and requirements, generate an OpenAPI definition from that prototype, and use the result to refine the design. This exploratory workflow blurs the usual boundary between code-first and design-first development. section 6.3.2

Code-first is quick for simple API changes and familiar to developers who move directly from requirements to implementation. Its risk is functional delivery without sufficient attention to usability and consistency from the consumer’s perspective. section 1.5.1

How Automating API Delivery covers it

How deep it goes
Describes the workflow, generated-definition review, source-of-truth comparison, and exploratory prototyping, but gives no tool commands.
Examples
Uses generated OpenAPI definitions, schemas, examples, client SDKs, API references, and exploratory API prototypes.
What it assumes
Assumes familiarity with API implementation and business requirements while noting that API-definition tooling may be unfamiliar to developers.
What you can do after
Apply it by implementing API changes, generating an OpenAPI definition, checking its consumer-facing quality, and producing downstream artifacts.
How it connects
Contrasts with design-first development and relates generated definitions to OpenAPI, API documentation, client SDKs, and API design.

Also explained in

Compare how 4 books explain code-first approach →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Automating API Delivery. The section links point to the parts of the book it draws on.