Working in this repo until we get the first endpoint or two in place.
Our spec is organized semantically, by resource, instead of syntactically, by OpenAPI element.
.
├── Lob-API-public.yml # base file (metadata, tags, servers, ...)
└── resources
├── addresses # elements specific to addresses
│ ├── addresses.yml # operations on /addresses
│ ├── address.yml # operations on /addresses/{id}
│ ├── attributes
│ │ ├── adr_id.yml
│ │ └── ...
│ ├── models
│ │ └── address.yml
│ └── responses
│ ├── address.yml
│ └── all_addresses.yml
├── postcards # elements specific to postcards
│ ├── postcards.yml # operations on /postcards
│ ├── postcard.yml # operations on /postcards/{id}
│ └── ...
└── shared # elements shared by multiple resources
├── headers.yml
├── parameters.yml
└── models
└── list.yml
Our style guide is an extension of Spectral's OpenAPI ruleset. Spectral's ruleset goes beyond the OpenAPI v3 standard to incorporate a recommended set of best practices.
Spectral runs in CI on push and pull request. You can also run Spectral locally using the Spectral CLI and/or via the stoplight.spectral VS Code extension.
Additional linting is provided by 42crunch.vscode-openapi. A second linter will be added to CI, as a backup to Spectral.
To preview the spec using redoc:
- install 42crunch.vscode-openapi in VS Code
- go to
Settings => Extenstions => OpenAPI
- set
Default Preview Renderer
toredoc
- open
Lob-API-public.yml
- click on the preview icon at the upper right hand corner of the panel.
- Drill down into the documentation to make sure that your examples are populating correctly.
- Run the code samples to be sure they are correct.
- Compare the response you get to the example response.
A lot of tooling for working with OpenAPI specs does not support the full specification. In particular, many tools do not support multiple files specs. To use such a tool, bundle the spec into a single file using make bundle
.
The tool used by make bundle
can do much more than bundle a multiple file spec into a single file. It can convert specs between YAML
and JSON
, fully dereference a spec, and more.
The API tooling Notion page.