What is an OpenAPI Specification?
The OpenAPI Specification (OAS) is a framework used by developers to document REST APIs. The specification is written in JSON or YAML and contains all of your endpoints, parameters, schemas, and authentication schemes. Fern is compatible with the latest OAS release, which is currently v3.1.1.
Below is an example of an OpenAPI file:
openapi.yml
Best practices
Follow these best practices to ensure your OpenAPI specification generates high-quality SDKs and documentation:
- Organize with proper project structure. Follow the instructions at Project structure to clearly organize the directories that contain your definition and other related files.
- Add
operationId
to endpoints. Include a clearoperationId
for each endpoint to control the function names generated in your SDKs. (Or use extensions to customize group and method names.) - Reference schemas instead of inlining. Define reusable schemas in the
components/schemas
section and reference them with$ref
. This promotes consistency, reduces duplication, and makes maintenance easier.Example of referencing schemas
openapi.yml - Use overrides and Fern extensions for customization. Customize your specification using Fern extensions housed in an overrides file. This lets you modify generation behavior without changing your core OpenAPI definition.
Once your OpenAPI spec follows these practices, you’re ready to set up your fern folder.
Set up your fern folder
Considering options to generate an OpenAPI spec? Get live support here
Start by initializing your fern folder with an OpenAPI spec
This will initialize a directory like the following