-
Notifications
You must be signed in to change notification settings - Fork 3
Add revamped Typescript Quickstart page #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
45d9e59
Add revamped Typescript Quickstart page
devalog cf85ae0
Fix typos on quickstart page
devalog ff36f1a
Fix OpenAPI nit, add todo for generators.yml, show generators.yml fil…
devalog c6078c0
Add in AsyncAPI flow, outputSourceFiles option, and --organization flag
devalog cdbd4c8
Remove config page from this PR, will add in a different one.
devalog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,136 @@ | ||
| --- | ||
| title: Typescript Quickstart | ||
| title: TypeScript Quickstart | ||
| description: Get started quickly with the Fern Typescript SDK. | ||
| --- | ||
|
|
||
| # Typescript Quickstart | ||
| <Warning title='Schedule a Demo'> | ||
| Generating SDKs often requires understanding the state of your OpenAPI Specification as well as | ||
| your specific requirements. For the ideal experience, we **strongly recommend** scheduling a | ||
| [demo](https://buildwithfern.com/contact) or [emailing us](mailto:[email protected]) to get started. | ||
| </Warning> | ||
|
|
||
| Follow these steps to quickly get up and running with the Fern Typescript SDK. | ||
| Generate a TypeScript SDK by following the instructions on this page. | ||
|
|
||
| <Steps> | ||
| ### Install the Fern CLI | ||
|
|
||
| Run the following command to install the CLI tool or update it to the latest version: | ||
|
|
||
| ```bash | ||
| npm install -g fern-api | ||
| ``` | ||
|
|
||
| ### Initialize the Fern Folder | ||
|
|
||
| You can use either the Open API definition or Fern Definition to generate your SDK. | ||
|
|
||
| <AccordionGroup> | ||
| <Accordion title="Option 1: OpenAPI"> | ||
| Initialize the Fern folder using your OpenAPI Specification. Run one of the following commands based on your spec's location: | ||
|
|
||
| <Tip> | ||
| 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. | ||
| </Tip> | ||
|
|
||
| <CodeBlocks> | ||
|
|
||
| <CodeBlock title="Spec stored locally"> | ||
| ```bash | ||
| fern init --openapi path/to/openapi.yml | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| <CodeBlock title="Spec hosted on web"> | ||
| ```bash | ||
| fern init --openapi https://api.example.com/openapi.yml | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| </CodeBlocks> | ||
|
|
||
| <Info> | ||
| Enter your organization name when prompted. The organization name must be configured in `fern.config.json` in order to successfully generate your SDK. | ||
| </Info> | ||
|
|
||
| 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. | ||
|
|
||
| ```bash | ||
| fern/ | ||
| ├─ fern.config.json # root-level configuration | ||
| └─ api/ # your API | ||
| ├─ generators.yml # generators you're using | ||
| └─ openapi/ | ||
| ├─ openapi.yml # API-level configuration | ||
| ``` | ||
| </Accordion> | ||
| <Accordion title="Option 2: Fern Definition"> | ||
|
|
||
| Initialize the Fern folder using the Fern Definition by running the following command: | ||
|
|
||
| ```bash | ||
| fern init | ||
| ``` | ||
| <Info> | ||
| Enter your organization name when prompted. The organization name must be configured in `fern.config.json` in order to sucessfully generate your SDK. | ||
| </Info> | ||
|
|
||
| This creates a `fern` folder in your current directory with the Fern Definition. | ||
|
|
||
| ```bash | ||
| fern/ | ||
| ├─ fern.config.json # root-level configuration | ||
| ├─ generators.yml # generators you're using | ||
| └─ definition/ | ||
| ├─ api.yml # API-level configuration | ||
| └─ imdb.yml # endpoints, types, and errors | ||
| ``` | ||
|
|
||
| <Note> | ||
| `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. | ||
| </Note> | ||
|
|
||
| </Accordion> | ||
| </AccordionGroup> | ||
devalog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Pass `fern check` | ||
|
|
||
| Run `fern check` to ensure that your API Definition is valid. If there are any errors, | ||
| fix them before proceeding. | ||
|
|
||
| <Note> | ||
| If you're using an OpenAPI Specification, check out all of our | ||
| [supported extensions](/learn/api-definition/openapi/extensions). | ||
| </Note> | ||
|
|
||
| ### Generate the SDK | ||
|
|
||
| Add the TypeScript SDK using the following command: | ||
|
|
||
| ```bash | ||
| fern add fern-typescript-node-sdk --group sdk | ||
devalog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| Then, generate the SDK: | ||
|
|
||
| ```bash | ||
| fern generate --group sdk | ||
| ``` | ||
|
|
||
| This creates a `sdks` folder in your current directory. The resulting folder structure looks like this: | ||
|
|
||
|
|
||
| ```bash | ||
| fern/ # created in step 1 | ||
| sdks/ # created by fern generate --group sdk | ||
| ├─ typescript | ||
| ├─ cjs/ | ||
| ├─ api/ | ||
| ├─ core/ | ||
| └─ errors/ | ||
| └─ esm/ | ||
| ├─ api/ | ||
| ├─ core/ | ||
| └─ errors/ | ||
| ``` | ||
|
|
||
| </Steps> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.