生成 SDK
生成 SDK
按照此页面上的说明生成 Swift SDK。
Initialize the fern folder
Initialize the fern folder with your existing OpenAPI specification. Specify your organization name using the --organization flag.
OpenAPI accepts both JSON and YAML formats.
This creates a fern folder in your current directory.
Validate your API definition
Check that your API definition is valid, and fix errors before proceeding:
添加 SDK 生成器
运行以下命令将 Swift SDK 生成器添加到 generators.yml 中:
此命令将以下 group 添加到 generators.yml 中:
生成 SDK
运行以下命令来生成你的 SDK:
The first time you run fern generate, you must log in. Confirm the prompt and choose any of the login methods to authenticate, then generation continues automatically.
fern generate creates a sdks folder in your current directory. The resulting folder structure looks like this:
Set up GitHub repositories
Fern uses a multi-repo structure: your source repository contains the fern/ folder, and each SDK gets its own separate repository.
- Create a source repository for your
fern/folder if you don’t have one already (e.g.,your-org/your-api-definitions). - Create an SDK repository for your SDK (e.g.,
your-org/your-api-swift-sdk). - Install the Fern GitHub App on both repositories.