Skip to content

Commit 51419fb

Browse files
authored
(cli/api definitions) Document fern export command (#842)
1 parent 5999643 commit 51419fb

File tree

3 files changed

+39
-16
lines changed

3 files changed

+39
-16
lines changed

fern/products/api-def/ferndef-pages/export-openapi.mdx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,16 @@ title: Export from Fern Definition to OpenAPI
33
description: Export your Fern Definition files to OpenAPI using Fern's OpenAPI generator.
44
---
55

6-
To prevent lock-in to the Fern Definition format, we provide a generator that will export your Fern Def files to OpenAPI 3.1.
7-
This lets you switch to using OpenAPI at any time, or use your API definition with OpenAPI tools.
8-
To convert your Fern Definition to OpenAPI, use the `fern-openapi` generator.
6+
To prevent lock-in to the Fern Definition format, you can export your API definition to OpenAPI 3.1 at any time [using the `fern export` command](/cli-api-reference/cli-reference/commands#fern-export).
97

10-
Update your `generators.yml` file:
8+
If you have multiple APIs defined in your `fern/apis/` folder, use `--api` to specify which API to export.
119

12-
<CodeBlock title="generators.yml">
13-
```yaml
14-
- name: fernapi/fern-openapi
15-
version: 0.0.31
16-
config:
17-
format: yaml # options are yaml or json
18-
output:
19-
location: local-file-system
20-
path: ../openapi # relative path to output location
21-
```
22-
</CodeBlock>
10+
<CodeBlock title="terminal">
11+
```bash
12+
fern export path/to/openapi.yml
13+
fern export path/to/openapi.json
2314

15+
# Specify API to export
16+
fern export --api public-api path/to/openapi.yml
17+
```
18+
</CodeBlock>

fern/products/cli-api-reference/pages/commands.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ hideOnThisPage: true
1212
| [`fern upgrade`](#fern-upgrade) | Update Fern CLI & generators to latest versions |
1313
| [`fern login`](#fern-login) | Login to Fern CLI via GitHub or Google |
1414
| [`fern logout`](#fern-logout) | Log out of the Fern CLI |
15+
| [`fern export`](#fern-export) | Export an OpenAPI spec for your API |
1516

1617
## Documentation Commands
1718

@@ -140,6 +141,33 @@ hideOnThisPage: true
140141
</Tip>
141142
</Accordion>
142143

144+
<Accordion title="fern export">
145+
146+
Use `fern export` to generate an OpenAPI spec for your API.
147+
148+
This command is useful when you've defined your API in a format other than OpenAPI (such as the [Fern Definition](/api-definitions/ferndef/overview)) and need to export it as an OpenAPI spec for integration with other tools or services.
149+
150+
151+
<CodeBlock title="terminal">
152+
```bash
153+
fern export [--api <api>] path/to/openapi.yml
154+
fern export [--api <api>] path/to/openapi.json
155+
```
156+
</CodeBlock>
157+
158+
### api
159+
160+
Use `--api` to specify which API to export when you have multiple APIs defined in your `fern/apis/` folder.
161+
162+
<CodeBlock title="terminal">
163+
```bash
164+
fern export --api public-api path/to/openapi.yml
165+
fern export --api public-api path/to/openapi.json
166+
```
167+
</CodeBlock>
168+
169+
</Accordion>
170+
143171
<Accordion title="fern generate">
144172
Use `fern generate` to run the Fern compiler and create SDKs for your API.
145173

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
You can initialize your fern folder with either a Fern Definition or OpenAPI specification.
22

33
<Tip>
4-
You can always convert a Fern Definition to OpenAPI or OpenAPI to a Fern Definition later on.
4+
You can always convert a [Fern Definition to OpenAPI](/api-definitions/ferndef/export-openapi) or OpenAPI to a Fern Definition later on.
55
</Tip>

0 commit comments

Comments
 (0)