Merging multiple API specs
Fern supports intelligently merging multiple API Definitions into a single SDK. This feature is useful when you have multiple micro-services that you would like to expose as a single SDK.
Single API
You can specify your API Definition in generators.yml
. In the normal case, you would have
a single API Definition.
Multiple APIs
If you have multiple API Definitions, you can specify them in generators.yml
as follows:
Namespaced APIs
If you have multiple API Definitions that have overlapping schema names or operation names,
you can specify a namespace
for each API Definition. A namespace is often used to
handle API versioning. Note these are nested under a namespaces
block.
Depending on APIs
Fern allows you to import other APIs into your API. This is often useful if:
- you want to reuse another API’s types in your API
- you want to combine multiple APIs into one SDK (similar to the AWS SDK)
This feature is only available if you use a Fern Definition.
Register your API
The first step is to register the API you want to depend on. To do this, use the register command:
You can set the version of your dependency by using the --version
flag:
Depending on the registered API
To add a dependency on another API, you simply create a folder in your Fern Definition to “house” the dependency.
In __package__.yml
, you can specify the API you want to depend on:
At runtime, the __package__.yml
file will effectively
be replaced with the API you’re depending on.