Skip to navigation

Set up local SDK previews

View as Markdown

Once you configure your SDK, you can use the --preview flag to test generated SDK code locally before publishing. This allows quick iteration on your SDK as you develop:

# Preview all SDKs
fern generate --preview
# Preview SDK for a specific language
fern generate --group <language>-sdk --preview

--preview generates your SDK code into a local .preview/ folder within your fern folder. No changes are published to package managers or GitHub.

--preview preserves any custom code you added to your SDK.

Example usage

Here’s an example of how you can preview a Python SDK.

1

Generator configuration

sdk-config.yml
schemaVersion: sdk-config/v1
source:
specs:
- id: imdb
type: openapi
path: ./openapi/openapi.yml
targets:
- language: python
package:
packageName: imdb
generation:
naming:
clientName: imdb
output:
delivery: github
github:
repository: imdb/imdb-python
publish:
registry: pypi
username: __token__
password: ${PYPI_TOKEN}
2

Invoke the Fern CLI

fern generate --target python --preview
3

Preview your SDK

The resulting folder structure will look like this:

fern
fern.config.json
.preview
fern-python-sdk
...
sdk-config.yml
openapi
openapi.yml