Skip to content

Commit

Permalink
fix(cli): support x-fern-parameter-name on path parameters (#4349)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Aug 20, 2024
1 parent bd26467 commit d9e4fed
Show file tree
Hide file tree
Showing 44 changed files with 2,917 additions and 133 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/openapi-ir-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install

- name: Install Fern
run: npm install -g fern-api
Expand All @@ -32,8 +35,7 @@ jobs:
env:
FERN_TOKEN: dummy
run: |
cd packages/cli/openapi-ir-sdk
pnpm generate
pnpm openapi-ir:generate
- name: Ensure no changes to git-tracked files
run: git --no-pager diff --exit-code
13 changes: 11 additions & 2 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,18 @@ navigation:
contents:
- page: Overview
path: ./pages/api-definition/openapi/openapi-overview.mdx
- page: OpenAPI Extensions
path: ./pages/api-definition/openapi/extensions.mdx
- section: Extensions
slug: extensions
contents:
- page: SDK Method Names
path: ./pages/api-definition/openapi/extensions/method-names.mdx
slug: method-names
- page: Parameter Names
path: ./pages/api-definition/openapi/extensions/parameter-names.mdx
slug: parameter-names
- page: Other
path: ./pages/api-definition/openapi/extensions/others.mdx
slug: others
- page: OpenAPI Examples
path: ./pages/api-definition/openapi/examples.mdx
- page: OpenAPI Overrides
Expand Down
50 changes: 50 additions & 0 deletions fern/pages/api-definition/openapi/extensions/method-names.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Customize SDK Method Names
description: Use `x-fern-sdk-method-name` and `x-fern-sdk-group-name` to finetune SDK naming.
---

<Note>
The `x-fern-sdk-group-name` and `x-fern-sdk-method-name` extensions allow you to customize the generated SDK method
names.
</Note>

## Usage

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

```yaml title="openapi.yaml"
paths:
/users:
post:
x-fern-sdk-group-name: users
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()`:

```yaml title="openapi.yaml"
paths:
/send:
post:
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()`:

```yaml title="openapi.yaml"
paths:
/users/notifications:
post:
x-fern-sdk-group-name:
- users
- notifications
x-fern-sdk-method-name: send
```
Loading

0 comments on commit d9e4fed

Please sign in to comment.