Customize SDK Method Names

Operation IDs

By default, if you have no extensions present, Fern will try to use your operation ID to generate idiomatic method names for the SDK. We typically recommend formatting your operation IDs like {tag_name}_{operation_name}.

For example, for an endpoint that has the tag users and the operation id users_get, we will generate an SDK method that is users.get(). If your operation id does not start with a tag, then we will simply use it as the method name.

Usage

The x-fern-sdk-group-name and x-fern-sdk-method-name extensions allow you to customize the generated SDK method names.

In the example below, Fern will generate a method called client.users.create() for the POST /users endpoint.

openapi.yaml
1paths:
2 /users:
3 post:
4 x-fern-sdk-group-name: users
5 x-fern-sdk-method-name: create

Top level methods

If you omit the x-fern-sdk-group-name extension, then the generated SDK method will live at the root. In the example below, Fern will generate a method called client.send():

openapi.yaml
1paths:
2 /send:
3 post:
4 x-fern-sdk-method-name: send

Multiple levels of nesting

If you add more than one x-fern-sdk-group-name extension, then the generated SDK will nest group names. The order of the group names is preserved in the generated SDK method.

In the example below, Fern will generate a method called client.users.notifications.send():

openapi.yaml
1paths:
2 /users/notifications:
3 post:
4 x-fern-sdk-group-name:
5 - users
6 - notifications
7 x-fern-sdk-method-name: send