Generating OpenAPI from Code

OpenAPI and Express with Optic

To begin using Optic with your API you first need an OpenAPI file describing your API. This YAML or JSON file can be written by hand or generated from your code. This document describes the recommended process for generating a new OpenAPI file for an Express project.

There are a couple of ways to generate an OpenAPI spec from your express app, the one we recommend is connecting up Optic to your integration tests to generate a spec.

Alternatively, there are some open source tools that you can use that also support OpenAPI spec generation:


Optic supports OpenAPI 3 and 3.1 - make sure that you opt-in to OpenAPI V3 generation when setting up your generator

What's next

Automate your OpenAPI generation and test your API specifications by setting up Optic in CI.