Skip to content

Commit fdb4fe6

Browse files
committed
Break typescript quickstart content into reusable snippets
1 parent 20fb6db commit fdb4fe6

File tree

9 files changed

+139
-139
lines changed

9 files changed

+139
-139
lines changed

fern/products/sdks/overview/python/quickstart.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ title: Python Quickstart
33
description: Get started quickly with the Fern Python SDK.
44
---
55

6-
# Python Quickstart
7-
8-
Follow these steps to quickly get up and running with the Fern Python SDK.
6+
Generate a Python SDK by following the instructions on this page.

fern/products/sdks/overview/typescript/quickstart.mdx

Lines changed: 11 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -3,134 +3,30 @@ title: TypeScript Quickstart
33
description: Get started quickly with the Fern Typescript SDK.
44
---
55

6-
<Warning title='Schedule a Demo'>
7-
Generating SDKs often requires understanding the state of your OpenAPI Specification as well as
8-
your specific requirements. For the ideal experience, we **strongly recommend** scheduling a
9-
[demo](https://buildwithfern.com/contact) or [emailing us](mailto:[email protected]) to get started.
10-
</Warning>
6+
<Markdown src="/products/sdks/snippets/demo-warning.mdx"/>
117

128
Generate a TypeScript SDK by following the instructions on this page.
139

1410
<Steps>
15-
### Install the Fern CLI
16-
17-
Run the following command to install the CLI tool or update it to the latest version:
18-
19-
```bash
20-
npm install -g fern-api
21-
```
11+
<Markdown src="/products/sdks/snippets/install-cli.mdx"/>
2212

2313
### Initialize the Fern Folder
2414

2515
You can use either the OpenAPI definition, AsyncAPI definition, or Fern Definition to generate your SDK.
2616

2717
<AccordionGroup>
28-
<Accordion title="Option 1: OpenAPI">
29-
Initialize the Fern folder using your OpenAPI Specification. Run one of the following commands based on your spec's location.
30-
31-
<Tip>
32-
Fern can handle both JSON and YML formats for OpenAPI specifications, and the --openapi flag accepts either format, so you can use whichever format your API spec is available in.
33-
</Tip>
34-
35-
<Info>
36-
`--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully generate your SDK.
37-
</Info>
38-
39-
<CodeBlocks>
40-
41-
<CodeBlock title="Local file">
42-
```bash
43-
fern init --openapi path/to/openapi.yml --organization <YourOrganization>
44-
```
45-
</CodeBlock>
46-
47-
<CodeBlock title="Web-hosted file">
48-
```bash
49-
fern init --openapi https://api.example.com/openapi.yml --organization <YourOrganization>
50-
```
51-
</CodeBlock>
52-
53-
</CodeBlocks>
54-
55-
This creates a `fern` folder in your current directory with the OpenAPI Specification. The exact folder structure might look different depending on your initial input files.
56-
57-
```bash
58-
fern/
59-
├─ fern.config.json # root-level configuration
60-
└─ api/ # your API
61-
├─ generators.yml # generators you're using
62-
└─ openapi/
63-
├─ openapi.yml # API-level configuration
64-
```
18+
<Accordion title="Option 1: OpenAPI">
19+
<Markdown src="/products/sdks/snippets/option-1-openapi.mdx"/>
6520
</Accordion>
21+
6622
<Accordion title="Option 2: AsyncAPI">
67-
Initialize the Fern folder using your AsyncAPI Specification. Run one of the following commands based on your spec's location.
68-
69-
<Tip>
70-
Fern can handle both JSON and YML formats for AsyncAPI specifications, and the --openapi flag accepts either format, so you can use whichever format your API spec is available in.
71-
</Tip>
72-
73-
<Info>
74-
`--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully generate your SDK.
75-
</Info>
76-
77-
<CodeBlocks>
78-
79-
<CodeBlock title="Local file">
80-
```bash
81-
fern init --asyncapi path/to/asyncapi.yml --organization <YourOrganization>
82-
```
83-
</CodeBlock>
84-
85-
<CodeBlock title="Web-hosted file">
86-
```bash
87-
fern init --asyncapi https://api.example.com/asyncapi.yml --organization <YourOrganization>
88-
```
89-
</CodeBlock>
90-
91-
</CodeBlocks>
92-
93-
This creates a `fern` folder in your current directory with the AsyncAPI Specification. The exact folder structure might look different depending on your initial input files.
94-
95-
```bash
96-
fern/
97-
├─ fern.config.json # root-level configuration
98-
└─ api/ # your API
99-
├─ generators.yml # generators you're using
100-
└─ openapi/
101-
├─ openapi.yml # API-level configuration
102-
```
23+
<Markdown src="/products/sdks/snippets/option-2-asyncapi.mdx"/>
10324
</Accordion>
25+
10426
<Accordion title="Option 3: Fern Definition">
27+
<Markdown src="/products/sdks/snippets/option-3-fern-def.mdx"/>
10528

106-
1. Initialize the Fern folder using the Fern Definition by running the following command:
107-
108-
```bash
109-
fern init --organization <YourOrganization>
110-
```
111-
112-
<Info>
113-
`--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully generate your SDK.
114-
</Info>
115-
116-
This creates a `fern` folder in your current directory with the Fern Definition.
117-
118-
```bash
119-
fern/
120-
├─ fern.config.json # root-level configuration
121-
├─ generators.yml # generators you're using
122-
└─ definition/
123-
├─ api.yml # API-level configuration
124-
└─ imdb.yml # endpoints, types, and errors
125-
```
126-
127-
<Note>
128-
`imdb.yml` contains an example movies API. If you’re just generating an SDK for test purposes, you can leave this file as it is. To generate an SDK for your own API instead of the example movies API, replace `imdb.yml` with your own endpoints, types, and errors before proceeding with the rest of this page.
129-
</Note>
130-
131-
{/* TODO: show want generators.yml looks like, link out to configuration.md */}
132-
133-
1. Add the config option `outputSourceFiles: true` to `generators.yml`. This ensures your SDK contains `.ts` files instead of compiled output.
29+
1. Add the config option `outputSourceFiles: true` to `generators.yml`. This ensures your SDK contains `.ts` files instead of compiled output.
13430

13531
```yaml {11-12}
13632
# yaml-language-server: $schema=https://schema.buildwithfern.dev/generators-yml.json
@@ -146,22 +42,10 @@ Generate a TypeScript SDK by following the instructions on this page.
14642
config:
14743
outputSourceFiles: true
14844
```
149-
150-
151-
152-
15345
</Accordion>
15446
</AccordionGroup>
15547
156-
### Pass `fern check`
157-
158-
Run `fern check` to ensure that your API Definition is valid. If there are any errors,
159-
fix them before proceeding.
160-
161-
<Note>
162-
If you're using an OpenAPI Specification, check out all of our
163-
[supported extensions](/learn/api-definition/openapi/extensions).
164-
</Note>
48+
<Markdown src="/products/sdks/snippets/pass-fern-check.mdx"/>
16549
16650
### Add the SDK generator
16751
@@ -182,16 +66,7 @@ Generate a TypeScript SDK by following the instructions on this page.
18266
location: local-file-system
18367
path: ../sdks/typescript
18468
```
185-
### Generate the SDK
186-
187-
Generate the SDK:
188-
189-
```bash
190-
fern generate --group sdk
191-
```
192-
193-
This creates a `sdks` folder in your current directory. The resulting folder structure looks like this:
194-
69+
<Markdown src="/products/sdks/snippets/generate-sdk.mdx"/>
19570
19671
```bash
19772
fern/ # created in step 1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Warning title='Schedule a Demo'>
2+
Generating SDKs often requires understanding the state of your OpenAPI Specification as well as
3+
your specific requirements. For the ideal experience, we **strongly recommend** scheduling a
4+
[demo](https://buildwithfern.com/contact) or [emailing us](mailto:[email protected]) to get started.
5+
</Warning>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Generate the SDK
2+
3+
Generate the SDK:
4+
5+
```bash
6+
fern generate --group sdk
7+
```
8+
This creates a `sdks` folder in your current directory. The resulting folder structure looks like this:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Install the Fern CLI
2+
3+
Run the following command to install the CLI tool or update it to the latest version:
4+
5+
```bash
6+
npm install -g fern-api
7+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Initialize the Fern folder using your OpenAPI Specification. Run one of the following commands based on your spec's location.
2+
3+
<Tip>
4+
Fern can handle both JSON and YML formats for OpenAPI specifications, and the --openapi flag accepts either format, so you can use whichever format your API spec is available in.
5+
</Tip>
6+
7+
<Info>
8+
`--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully generate your SDK.
9+
</Info>
10+
11+
<CodeBlocks>
12+
13+
<CodeBlock title="Local file">
14+
```bash
15+
fern init --openapi path/to/openapi.yml --organization <YourOrganization>
16+
```
17+
</CodeBlock>
18+
19+
<CodeBlock title="Web-hosted file">
20+
```bash
21+
fern init --openapi https://api.example.com/openapi.yml --organization <YourOrganization>
22+
```
23+
</CodeBlock>
24+
25+
</CodeBlocks>
26+
27+
This creates a `fern` folder in your current directory with the OpenAPI Specification. The exact folder structure might look different depending on your initial input files.
28+
29+
```bash
30+
fern/
31+
├─ fern.config.json # root-level configuration
32+
└─ api/ # your API
33+
├─ generators.yml # generators you're using
34+
└─ openapi/
35+
├─ openapi.yml # API-level configuration
36+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Initialize the Fern folder using your AsyncAPI Specification. Run one of the following commands based on your spec's location.
2+
3+
<Tip>
4+
Fern can handle both JSON and YML formats for AsyncAPI specifications, and the --openapi flag accepts either format, so you can use whichever format your API spec is available in.
5+
</Tip>
6+
7+
<Info>
8+
`--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully generate your SDK.
9+
</Info>
10+
11+
<CodeBlocks>
12+
13+
<CodeBlock title="Local file">
14+
```bash
15+
fern init --asyncapi path/to/asyncapi.yml --organization <YourOrganization>
16+
```
17+
</CodeBlock>
18+
19+
<CodeBlock title="Web-hosted file">
20+
```bash
21+
fern init --asyncapi https://api.example.com/asyncapi.yml --organization <YourOrganization>
22+
```
23+
</CodeBlock>
24+
25+
</CodeBlocks>
26+
27+
This creates a `fern` folder in your current directory with the AsyncAPI Specification. The exact folder structure might look different depending on your initial input files.
28+
29+
```bash
30+
fern/
31+
├─ fern.config.json # root-level configuration
32+
└─ api/ # your API
33+
├─ generators.yml # generators you're using
34+
└─ openapi/
35+
├─ openapi.yml # API-level configuration
36+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
1. Initialize the Fern folder using the Fern Definition by running the following command:
2+
3+
```bash
4+
fern init --organization <YourOrganization>
5+
```
6+
7+
<Info>
8+
`--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully generate your SDK.
9+
</Info>
10+
11+
This creates a `fern` folder in your current directory with the Fern Definition.
12+
13+
```bash
14+
fern/
15+
├─ fern.config.json # root-level configuration
16+
├─ generators.yml # generators you're using
17+
└─ definition/
18+
├─ api.yml # API-level configuration
19+
└─ imdb.yml # endpoints, types, and errors
20+
```
21+
22+
<Note>
23+
`imdb.yml` contains an example movies API. If you’re just generating an SDK for test purposes, you can leave this file as it is. To generate an SDK for your own API instead of the example movies API, replace `imdb.yml` with your own endpoints, types, and errors before proceeding with the rest of this page.
24+
</Note>
25+
26+
{/* TODO: show want generators.yml looks like, link out to configuration.md */}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Pass `fern check`
2+
3+
Run `fern check` to ensure that your API Definition is valid. If there are any errors,
4+
fix them before proceeding.
5+
6+
<Note>
7+
If you're using an OpenAPI Specification, check out all of our
8+
[supported extensions](/learn/api-definition/openapi/extensions).
9+
</Note>

0 commit comments

Comments
 (0)