You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/api-def/ferndef-pages/export-openapi.mdx
+10-15Lines changed: 10 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,21 +3,16 @@ title: Export from Fern Definition to OpenAPI
3
3
description: Export your Fern Definition files to OpenAPI using Fern's OpenAPI generator.
4
4
---
5
5
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).
9
7
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.
11
9
12
-
<CodeBlocktitle="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
|[`fern login`](#fern-login)| Login to Fern CLI via GitHub or Google |
14
14
|[`fern logout`](#fern-logout)| Log out of the Fern CLI |
15
+
|[`fern export`](#fern-export)| Export an OpenAPI spec for your API |
15
16
16
17
## Documentation Commands
17
18
@@ -140,6 +141,33 @@ hideOnThisPage: true
140
141
</Tip>
141
142
</Accordion>
142
143
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
+
143
171
<Accordion title="fern generate">
144
172
Use `fern generate` to run the Fern compiler and create SDKs for your API.
0 commit comments