@@ -22,106 +22,6 @@ be included in your SDK regardless of their audience tags.
2222
2323
2424<AccordionGroup >
25- <Accordion title = " Fern Definition" >
26-
27- Configuring audiences in a Fern Definition involves:
28-
29- 1 . Explicitly defining audiences in ` api.yml ` .
30- 1 . Configuring audiences for specific endpoints, types, and properties.
31- 1 . Apply audience filters to your SDK so only certain endpoints are passed to the generators.
32-
33- <Steps >
34- ### Defining audiences
35-
36- Audiences are explicitly declared in Fern Definition.
37- To use audiences in your Fern Definition, add them to ` api.yml ` .
38-
39- In the example below, we have created audiences for ` internal ` , ` beta ` , and ` customer ` groups:
40-
41- ``` yaml title='api.yml' {2-5}
42- name : api
43- audiences :
44- - internal
45- - beta
46- - customers
47- ` ` `
48- ### Apply audiences to your endpoints, types, and properties
49-
50- Once you've defined audiences, mark endpoints, types, or properties for a
51- particular consumer by adding an ` audience` with the relevant groups.
52-
53- <AccordionGroup>
54- <Accordion title="Endpoints">
55-
56- In this example, the `sendEmail` endpoint is only available to internal consumers :
57-
58- ` ` ` yaml title='user.yml' {6-7}
59- service:
60- base-path: /users
61- auth: true
62- endpoints:
63- sendEmail:
64- audiences:
65- - internal
66- path: /send-email
67- ...
68- ` ` `
69- </Accordion>
70- <Accordion title="Types">
71-
72- Types can also be marked for different audiences.
73-
74- In this example, the `Email` type is available to internal and beta consumers :
75-
76- ` ` ` yaml title='user.yml' {5-7}
77- Email:
78- properties:
79- subject: string
80- body: optional<string>
81- audiences:
82- - internal
83- - beta
84- ` ` `
85- </Accordion>
86- <Accordion title="Properties">
87- In this example, the `to` property is available to beta consumers only :
88-
89- ` ` ` yaml title='user.yml' {8-9}
90- Email:
91- properties:
92- subject: string
93- body: optional<string>
94- to:
95- type: string
96- docs: The recipient of the email
97- audiences:
98- - beta
99- ` ` `
100- </Accordion>
101- </AccordionGroup>
102-
103- # ## Set up SDK filters in `generators.yml`
104-
105- In `generators.yml`, you can apply audience filters so that only certain
106- endpoints are passed to the generators.
107-
108- The following example configures the SDKs to filter for `customers` :
109-
110- ` ` ` yaml title='generators.yml' {3-4}
111- groups:
112- external:
113- audiences:
114- - customers
115- generators:
116- ...
117- ` ` `
118- # ## Generate your SDK
119-
120- ` ` ` bash
121- fern generate --group sdk
122- ` ` `
123- </Steps>
124- </Accordion>
12525<Accordion title = " OpenAPI" >
12626
12727Configuring audiences in an OpenAPI spec involves:
@@ -236,4 +136,104 @@ groups:
236136
237137</Steps>
238138</Accordion>
139+ <Accordion title="Fern Definition">
140+
141+ Configuring audiences in a Fern Definition involves :
142+
143+ 1. Explicitly defining audiences in `api.yml`.
144+ 1. Configuring audiences for specific endpoints, types, and properties.
145+ 1. Apply audience filters to your SDK so only certain endpoints are passed to the generators.
146+
147+ <Steps>
148+ # ## Defining audiences
149+
150+ Audiences are explicitly declared in Fern Definition.
151+ To use audiences in your Fern Definition, add them to `api.yml`.
152+
153+ In the example below, we have created audiences for `internal`, `beta`, and `customer` groups :
154+
155+ ` ` ` yaml title='api.yml' {2-5}
156+ name: api
157+ audiences:
158+ - internal
159+ - beta
160+ - customers
161+ ` ` `
162+ # ## Apply audiences to your endpoints, types, and properties
163+
164+ Once you've defined audiences, mark endpoints, types, or properties for a
165+ particular consumer by adding an `audience` with the relevant groups.
166+
167+ <AccordionGroup>
168+ <Accordion title="Endpoints">
169+
170+ In this example, the `sendEmail` endpoint is only available to internal consumers :
171+
172+ ` ` ` yaml title='user.yml' {6-7}
173+ service:
174+ base-path: /users
175+ auth: true
176+ endpoints:
177+ sendEmail:
178+ audiences:
179+ - internal
180+ path: /send-email
181+ ...
182+ ` ` `
183+ </Accordion>
184+ <Accordion title="Types">
185+
186+ Types can also be marked for different audiences.
187+
188+ In this example, the `Email` type is available to internal and beta consumers :
189+
190+ ` ` ` yaml title='user.yml' {5-7}
191+ Email:
192+ properties:
193+ subject: string
194+ body: optional<string>
195+ audiences:
196+ - internal
197+ - beta
198+ ` ` `
199+ </Accordion>
200+ <Accordion title="Properties">
201+ In this example, the `to` property is available to beta consumers only :
202+
203+ ` ` ` yaml title='user.yml' {8-9}
204+ Email:
205+ properties:
206+ subject: string
207+ body: optional<string>
208+ to:
209+ type: string
210+ docs: The recipient of the email
211+ audiences:
212+ - beta
213+ ` ` `
214+ </Accordion>
215+ </AccordionGroup>
216+
217+ # ## Set up SDK filters in `generators.yml`
218+
219+ In `generators.yml`, you can apply audience filters so that only certain
220+ endpoints are passed to the generators.
221+
222+ The following example configures the SDKs to filter for `customers` :
223+
224+ ` ` ` yaml title='generators.yml' {3-4}
225+ groups:
226+ external:
227+ audiences:
228+ - customers
229+ generators:
230+ ...
231+ ` ` `
232+ # ## Generate your SDK
233+
234+ ` ` ` bash
235+ fern generate --group sdk
236+ ` ` `
237+ </Steps>
238+ </Accordion>
239239</AccordionGroup>
0 commit comments