Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 47 additions & 47 deletions fern/products/sdks/guides/configure-global-headers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,53 +28,6 @@ majority of requests, and marks them as global. You can manually configure addit
global headers in either `api.yml` (Fern Definition) or `openapi.yml`.

<AccordionGroup>
<Accordion title="Fern Definition">

To specify headers that are meant to be included on every request:

<CodeBlock title="api.yml">
```yaml {3}
name: api
headers:
X-App-Id: string
```
</CodeBlock>

### Global path parameters
You can also specify path parameters that are meant to be included on every request:

<CodeBlock title="api.yml">
```yaml
name: api
base-path: /{userId}/{orgId}
path-parameters:
userId: string
orgId: string
```
</CodeBlock>

#### Overriding the base path

If you have certain endpoints that do not live at the configured `base-path`, you can
override the `base-path` at the endpoint level.

```yml imdb.yml {5}
service:
endpoints:
getMovie:
method: POST
base-path: "override/{arg}"
path: "movies/{movieId}"
path-parameters:
arg: string
```

<Note>
You cannot yet specify query parameters that are meant to be included on every request.
If you'd like to see this feature, please upvote [this issue](https://github.com/fern-api/fern/issues/2930).
</Note>

</Accordion>
<Accordion title="OpenAPI">

For OpenAPI specifications, you can configure global headers in two ways:
Expand Down Expand Up @@ -123,5 +76,52 @@ class Client:
```


</Accordion>
<Accordion title="Fern Definition">

To specify headers that are meant to be included on every request:

<CodeBlock title="api.yml">
```yaml {3}
name: api
headers:
X-App-Id: string
```
</CodeBlock>

### Global path parameters
You can also specify path parameters that are meant to be included on every request:

<CodeBlock title="api.yml">
```yaml
name: api
base-path: /{userId}/{orgId}
path-parameters:
userId: string
orgId: string
```
</CodeBlock>

#### Overriding the base path

If you have certain endpoints that do not live at the configured `base-path`, you can
override the `base-path` at the endpoint level.

```yml imdb.yml {5}
service:
endpoints:
getMovie:
method: POST
base-path: "override/{arg}"
path: "movies/{movieId}"
path-parameters:
arg: string
```

<Note>
You cannot yet specify query parameters that are meant to be included on every request.
If you'd like to see this feature, please upvote [this issue](https://github.com/fern-api/fern/issues/2930).
</Note>

</Accordion>
</AccordionGroup>
32 changes: 16 additions & 16 deletions fern/products/sdks/guides/customize-method-names.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,6 @@ For OpenAPI, use the `x-fern-sdk-group-name` and `x-fern-sdk-method-name` extens
explicitly define your method name and grouping.

<AccordionGroup>
<Accordion title="Fern Definition">

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

```yaml title="users.yml" {4, 6}
services:
http:
UsersService:
base-path: /users # This defines the group/namespace for the methods
endpoints:
create: # This defines the specific method name within the group
method: POST
path: ""
```

</Accordion>
<Accordion title="OpenAPI">

In the example below, Fern will generate a
Expand Down Expand Up @@ -150,6 +134,22 @@ paths:
- notifications
x-fern-sdk-method-name: send
```
</Accordion>
<Accordion title="Fern Definition">

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

```yaml title="users.yml" {4, 6}
services:
http:
UsersService:
base-path: /users # This defines the group/namespace for the methods
endpoints:
create: # This defines the specific method name within the group
method: POST
path: ""
```

</Accordion>
</AccordionGroup>

Expand Down
200 changes: 100 additions & 100 deletions fern/products/sdks/guides/filter-your-endpoints-audiences.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,106 +22,6 @@ be included in your SDK regardless of their audience tags.


<AccordionGroup>
<Accordion title="Fern Definition">

Configuring audiences in a Fern Definition involves:

1. Explicitly defining audiences in `api.yml`.
1. Configuring audiences for specific endpoints, types, and properties.
1. Apply audience filters to your SDK so only certain endpoints are passed to the generators.

<Steps>
### Defining audiences

Audiences are explicitly declared in Fern Definition.
To use audiences in your Fern Definition, add them to `api.yml`.

In the example below, we have created audiences for `internal`, `beta`, and `customer` groups:

```yaml title='api.yml' {2-5}
name: api
audiences:
- internal
- beta
- customers
```
### Apply audiences to your endpoints, types, and properties

Once you've defined audiences, mark endpoints, types, or properties for a
particular consumer by adding an `audience` with the relevant groups.

<AccordionGroup>
<Accordion title="Endpoints">

In this example, the `sendEmail` endpoint is only available to internal consumers:

```yaml title='user.yml' {6-7}
service:
base-path: /users
auth: true
endpoints:
sendEmail:
audiences:
- internal
path: /send-email
...
```
</Accordion>
<Accordion title="Types">

Types can also be marked for different audiences.

In this example, the `Email` type is available to internal and beta consumers:

```yaml title='user.yml' {5-7}
Email:
properties:
subject: string
body: optional<string>
audiences:
- internal
- beta
```
</Accordion>
<Accordion title="Properties">
In this example, the `to` property is available to beta consumers only:

```yaml title='user.yml' {8-9}
Email:
properties:
subject: string
body: optional<string>
to:
type: string
docs: The recipient of the email
audiences:
- beta
```
</Accordion>
</AccordionGroup>

### Set up SDK filters in `generators.yml`

In `generators.yml`, you can apply audience filters so that only certain
endpoints are passed to the generators.

The following example configures the SDKs to filter for `customers`:

```yaml title='generators.yml' {3-4}
groups:
external:
audiences:
- customers
generators:
...
```
### Generate your SDK

```bash
fern generate --group sdk
```
</Steps>
</Accordion>
<Accordion title="OpenAPI">

Configuring audiences in an OpenAPI spec involves:
Expand Down Expand Up @@ -236,4 +136,104 @@ groups:

</Steps>
</Accordion>
<Accordion title="Fern Definition">

Configuring audiences in a Fern Definition involves:

1. Explicitly defining audiences in `api.yml`.
1. Configuring audiences for specific endpoints, types, and properties.
1. Apply audience filters to your SDK so only certain endpoints are passed to the generators.

<Steps>
### Defining audiences

Audiences are explicitly declared in Fern Definition.
To use audiences in your Fern Definition, add them to `api.yml`.

In the example below, we have created audiences for `internal`, `beta`, and `customer` groups:

```yaml title='api.yml' {2-5}
name: api
audiences:
- internal
- beta
- customers
```
### Apply audiences to your endpoints, types, and properties

Once you've defined audiences, mark endpoints, types, or properties for a
particular consumer by adding an `audience` with the relevant groups.

<AccordionGroup>
<Accordion title="Endpoints">

In this example, the `sendEmail` endpoint is only available to internal consumers:

```yaml title='user.yml' {6-7}
service:
base-path: /users
auth: true
endpoints:
sendEmail:
audiences:
- internal
path: /send-email
...
```
</Accordion>
<Accordion title="Types">

Types can also be marked for different audiences.

In this example, the `Email` type is available to internal and beta consumers:

```yaml title='user.yml' {5-7}
Email:
properties:
subject: string
body: optional<string>
audiences:
- internal
- beta
```
</Accordion>
<Accordion title="Properties">
In this example, the `to` property is available to beta consumers only:

```yaml title='user.yml' {8-9}
Email:
properties:
subject: string
body: optional<string>
to:
type: string
docs: The recipient of the email
audiences:
- beta
```
</Accordion>
</AccordionGroup>

### Set up SDK filters in `generators.yml`

In `generators.yml`, you can apply audience filters so that only certain
endpoints are passed to the generators.

The following example configures the SDKs to filter for `customers`:

```yaml title='generators.yml' {3-4}
groups:
external:
audiences:
- customers
generators:
...
```
### Generate your SDK

```bash
fern generate --group sdk
```
</Steps>
</Accordion>
</AccordionGroup>