9 CI/CD for API artifacts 2: Build-stage and API configuration deployment
This chapter explains how API teams extend CI/CD beyond code compilation to handle API artifacts produced after design approval. It shows how a pipeline can transform OpenAPI definitions by bundling multi-file specs, filtering out internal endpoints and unused components, sorting fields for consistency, and then storing the resulting artifact in an API registry or similar store so downstream stages can reuse it. The chapter also frames these activities as part of the build stage, where API definitions may be repackaged for external publication, documentation, or later automation.
It then explores how API simulations and SDK generation fit into the same build workflow. API mocks and stubs help teams continue development before the real service is ready, support isolated testing, and make it easier to reproduce real-world conditions such as latency or variable responses. The chapter also shows how to generate client SDKs from OpenAPI definitions, why SDKs improve developer experience, and what tradeoffs come with maintaining them, including versioning, language-specific upkeep, and release management. Generated SDKs, like other build artifacts, are stored in binary artifact repositories so later pipeline stages can retrieve them reliably.
Finally, the chapter moves into the deploy-and-test stage, where API gateway configuration is treated as code and promoted through environments using GitOps and APIOps practices. It contrasts push-based and pull-based deployment models, emphasizing declarative configuration, versioned history, automated reconciliation, and the reduction of manual gateway changes. Through examples with Kong and Kusk, the chapter shows how pipelines can deploy backend services, apply gateway routing, run conformance tests, and label verified API definitions in the registry. Overall, it presents a full workflow for publishing, simulating, packaging, deploying, and validating APIs as part of an automated delivery process.
The APIOps practices discussed in this chapter
Example of API definition transformation in the pipeline
API simulations provide an alternative to the real API to support development and testing.
Updating the pipeline to generate an SDK
Deploying API configuration to different environments in the pipeline
GitOps push-based deployments
GitOps pull-based deployment model
Managing multiple applications and environments using a pull-based GitOps model depicting the configuration for the different environments in one central configuration repository
Summary
- In the build phase of the deployment pipeline, the API definition files can be processed and transformed to prepare them for external publishing. This transformation can include filtering the OpenAPI API definition file, replacing values, sorting objects in the file, and so on.
- Processed API definition files can be stored in an API registry so that they can be accessed by teams, applications, and systems downstream of the deployment pipeline. An API registry serves as a catalog of the organization’s APIs and should have an API to enable programmatic access to API definition artifacts.
- A variety of libraries and code-generation services exist for generating SDKs from API definition files. Client API SDKs help provide a better developer experience for teams integrating with an API. SDK packages can be stored in a binary artifact repository.
- An APIOps deployment workflow follows the GitOps practice of storing configuration declaratively in version control. Changes are made by PR, and a deployment pipeline or Kubernetes operator is used to sync the configuration with the API gateway instance.
FAQ
What is the purpose of transforming API definition files in the build stage?
Transforming API definition files makes them suitable for publishing or downstream use. Common transformations include bundling multifile definitions, filtering out internal endpoints, removing unused components, sorting fields consistently, and converting formats so the artifact is ready for a developer portal, SDK generation, or other pipeline steps.Why would a pipeline bundle an OpenAPI definition before publishing it?
Bundling combines a multifile API definition into a single file. This simplifies publishing, makes the definition easier for tools to process, and provides a single artifact that can be filtered, validated, stored, or shared with other stages of the pipeline.How are internal API endpoints excluded from the published API definition?
Internal endpoints can be marked with an OpenAPI extension such asx-internal:true. The pipeline can then use filtering tools like openapi-filter to remove those objects so only externally intended endpoints are published.
Automating API Delivery ebook for free