OpenAPI Specification

Importing OpenAPI

To use an OpenAPI spec, you can pass in the filepath or URL.

To pass in an OpenAPI spec from a filepath:

1
2
npm install -g fern-api
fern init --openapi <filepath to openapi>

Alternatively, to point to the URL of an OpenAPI spec:

1
2
3
npm install -g fern-api
fern init --openapi <url to openapi>

Fern will generate the following directory with your OpenAPI spec inside of it.

1
2
3
4
5
6
fern/
├─ fern.config.json
└─ api/
  ├─ generators.yml
  └─ openapi/
    └─ openapi.json # <--- your openapi file

Run fern check to validate the OpenAPI spec. Resolve any errors. Having trouble? Reach out in the Fern Discord server.

If you're having trouble understanding the errors, run the command fern write-definition. This command will convert your OpenAPI spec into a Fern Definition. Read more.

If there are no errors, you can run fern generate.