-
Notifications
You must be signed in to change notification settings - Fork 3
Add Python quickstart and break TS quickstart into reusable snippets #22
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e1588db
fill out config file for python sdk
devalog 245e249
add client example
devalog 0132b36
fix code example
devalog fb629f4
code example nit
devalog 10b6978
Merge main into go-config branch
devalog 20fb6db
Add content to Go config page
devalog fdb4fe6
Break typescript quickstart content into reusable snippets
devalog d53dc52
add python quickstart
devalog 0198cdc
fill out python qs, make some changes to snippets
devalog 00459fd
fix some errors
devalog 0869511
fix some errors
devalog 78b8442
reset config file (didn't mean to add it here)
devalog 113e662
fix code sample tabbing
devalog 6cf5fb8
add note about paid plans to python qs
devalog e1237bb
small fix
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
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
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 |
|---|---|---|
|
|
@@ -3,6 +3,65 @@ title: Python Quickstart | |
| description: Get started quickly with the Fern Python SDK. | ||
| --- | ||
|
|
||
| # Python Quickstart | ||
| <Markdown src="/products/sdks/snippets/demo-warning.mdx"/> | ||
|
|
||
| Follow these steps to quickly get up and running with the Fern Python SDK. | ||
| Generate a Python SDK by following the instructions on this page. | ||
|
|
||
| <Steps> | ||
| <Markdown src="/products/sdks/snippets/install-cli.mdx"/> | ||
|
|
||
| ### Initialize the Fern Folder | ||
|
|
||
| You can use either the OpenAPI definition, AsyncAPI definition, or Fern | ||
| Definition to generate your SDK. | ||
|
|
||
| <AccordionGroup> | ||
| <Markdown src="/products/sdks/snippets/option-1-openapi.mdx"/> | ||
|
|
||
| <Markdown src="/products/sdks/snippets/option-2-asyncapi.mdx"/> | ||
|
|
||
| <Markdown src="/products/sdks/snippets/option-3-fern-def.mdx"/> | ||
|
|
||
| </AccordionGroup> | ||
|
|
||
| <Markdown src="/products/sdks/snippets/pass-fern-check.mdx"/> | ||
|
|
||
| ### Add the SDK generator | ||
|
|
||
| Add the Python SDK generator: | ||
|
|
||
| ```bash | ||
| fern add fern-python-sdk --group sdk | ||
| ``` | ||
|
|
||
| This command adds the following to `generators.yml`: | ||
|
|
||
| ```yaml | ||
| sdk: | ||
| generators: | ||
| - name: fernapi/fern-python-sdk | ||
| version: <Markdown src="/snippets/version-number.mdx"/> | ||
| output: | ||
| location: local-file-system | ||
| path: ../sdks/python | ||
| ``` | ||
|
|
||
| <Markdown src="/products/sdks/snippets/generate-sdk.mdx"/> | ||
|
|
||
| ```bash | ||
| fern/ # created in step 1 | ||
| sdks/ # created by fern generate --group sdk | ||
| ├─ python | ||
| ├─ __init__.py | ||
| ├─ client.py | ||
| ├─ core/ | ||
| └─ imdb/ # or the name of your API | ||
| ├─ errors/ | ||
| └─ types/ | ||
| ``` | ||
|
|
||
| <Note>Some files, including `pyproject.toml` and `README.md`, are only generated on paid plans. | ||
| To get the fully generated SDK, schedule a | ||
| [demo](https://buildwithfern.com/contact) or [email | ||
| us](mailto:[email protected]).</Note> | ||
| </Steps> | ||
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 |
|---|---|---|
|
|
@@ -3,208 +3,61 @@ title: TypeScript Quickstart | |
| description: Get started quickly with the Fern Typescript SDK. | ||
| --- | ||
|
|
||
| <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> | ||
| <Markdown src="/products/sdks/snippets/demo-warning.mdx"/> | ||
|
|
||
| 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 | ||
| ``` | ||
| <Markdown src="/products/sdks/snippets/install-cli.mdx"/> | ||
|
|
||
| ### Initialize the Fern Folder | ||
|
|
||
| You can use either the OpenAPI definition, AsyncAPI 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> | ||
|
|
||
| <Info> | ||
| `--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully generate your SDK. | ||
| </Info> | ||
|
|
||
| <CodeBlocks> | ||
|
|
||
| <CodeBlock title="Local file"> | ||
| ```bash | ||
| fern init --openapi path/to/openapi.yml --organization <YourOrganization> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| <CodeBlock title="Web-hosted file"> | ||
| ```bash | ||
| fern init --openapi https://api.example.com/openapi.yml --organization <YourOrganization> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| </CodeBlocks> | ||
|
|
||
| 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: AsyncAPI"> | ||
| Initialize the Fern folder using your AsyncAPI Specification. Run one of the following commands based on your spec's location. | ||
|
|
||
| <Tip> | ||
| 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. | ||
| </Tip> | ||
|
|
||
| <Info> | ||
| `--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully generate your SDK. | ||
| </Info> | ||
|
|
||
| <CodeBlocks> | ||
|
|
||
| <CodeBlock title="Local file"> | ||
| ```bash | ||
| fern init --asyncapi path/to/asyncapi.yml --organization <YourOrganization> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| <CodeBlock title="Web-hosted file"> | ||
| ```bash | ||
| fern init --asyncapi https://api.example.com/asyncapi.yml --organization <YourOrganization> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| </CodeBlocks> | ||
|
|
||
| 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. | ||
|
|
||
| ```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 3: Fern Definition"> | ||
|
|
||
| 1. Initialize the Fern folder using the Fern Definition by running the following command: | ||
|
|
||
| ```bash | ||
| fern init --organization <YourOrganization> | ||
| ``` | ||
|
|
||
| <Info> | ||
| `--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully 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> | ||
|
|
||
| {/* TODO: show want generators.yml looks like, link out to configuration.md */} | ||
|
|
||
| 1. Add the config option `outputSourceFiles: true` to `generators.yml`. This ensures your SDK contains `.ts` files instead of compiled output. | ||
|
|
||
| ```yaml {11-12} | ||
| # yaml-language-server: $schema=https://schema.buildwithfern.dev/generators-yml.json | ||
| default-group: local | ||
| groups: | ||
| local: | ||
| generators: | ||
| - name: fernapi/fern-typescript-node-sdk | ||
| output: | ||
| location: local-file-system | ||
| path: ../sdks/typescript | ||
| version: <Markdown src="/snippets/version-number.mdx"/> | ||
| config: | ||
| outputSourceFiles: true | ||
| ``` | ||
|
|
||
|
|
||
| <Markdown src="/products/sdks/snippets/option-1-openapi.mdx"/> | ||
|
|
||
| <Markdown src="/products/sdks/snippets/option-2-asyncapi.mdx"/> | ||
|
|
||
| <Markdown src="/products/sdks/snippets/option-3-fern-def.mdx"/> | ||
|
|
||
| </Accordion> | ||
| </AccordionGroup> | ||
|
|
||
| ### 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> | ||
|
|
||
| ### Add the SDK generator | ||
|
|
||
| Add the TypeScript SDK generator: | ||
|
|
||
| ```bash | ||
| fern add fern-typescript-node-sdk --group sdk | ||
| ``` | ||
|
|
||
| This command adds the following to `generators.yml`: | ||
|
|
||
| ```yaml | ||
| sdk: | ||
| generators: | ||
| - name: fernapi/fern-typescript-node-sdk | ||
| version: <Markdown src="/snippets/version-number.mdx"/> | ||
| output: | ||
| location: local-file-system | ||
| path: ../sdks/typescript | ||
| ``` | ||
| ### Generate the SDK | ||
|
|
||
| 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/ | ||
| ``` | ||
| <Markdown src="/products/sdks/snippets/pass-fern-check.mdx"/> | ||
|
|
||
| ### Add the SDK generator | ||
|
|
||
| Add the TypeScript SDK generator: | ||
|
|
||
| ```bash | ||
| fern add fern-typescript-node-sdk --group sdk | ||
| ``` | ||
|
|
||
| This command adds the following to `generators.yml`: | ||
|
|
||
| ```yaml | ||
| sdk: | ||
| generators: | ||
| - name: fernapi/fern-typescript-node-sdk | ||
| version: <Markdown src="/snippets/version-number.mdx"/> | ||
| output: | ||
| location: local-file-system | ||
| path: ../sdks/typescript | ||
| ``` | ||
| <Markdown src="/products/sdks/snippets/generate-sdk.mdx"/> | ||
|
|
||
| ```bash | ||
| fern/ # created in step 1 | ||
| sdks/ # created by fern generate --group sdk | ||
| ├─ typescript | ||
| ├─ cjs/ | ||
| ├─ api/ | ||
| ├─ core/ | ||
| └─ errors/ | ||
| └─ esm/ | ||
| ├─ api/ | ||
| ├─ core/ | ||
| └─ errors/ | ||
| ``` | ||
|
|
||
| </Steps> | ||
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <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> |
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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ### Generate the SDK | ||
|
|
||
| Generate the SDK: | ||
|
|
||
| ```bash | ||
| fern generate --group sdk | ||
| ``` | ||
|
|
||
| This creates a `sdks` folder in your current directory. The resulting folder structure looks like this: |
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ### 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 | ||
| ``` |
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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <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> | ||
|
|
||
| <Info> | ||
| `--organization <YourOrganization>` configures your organization name in `fern.config.json`. This is required in order to successfully generate your SDK. | ||
| </Info> | ||
|
|
||
| <CodeBlocks> | ||
|
|
||
| <CodeBlock title="Local file"> | ||
| ```bash | ||
| fern init --openapi path/to/openapi.yml --organization <YourOrganization> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| <CodeBlock title="Web-hosted file"> | ||
| ```bash | ||
| fern init --openapi https://api.example.com/openapi.yml --organization <YourOrganization> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| </CodeBlocks> | ||
|
|
||
| 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> |
Oops, something went wrong.
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.