@@ -225,6 +225,116 @@ $openapi = new OpenApi([
225225$json = \cebe\openapi\Writer::writeToJson($openapi);
226226```
227227
228+ Write empty Security Requirement Object (` {} ` ):
229+
230+ ``` php
231+ $openapi = new OpenApi([
232+ ...
233+ 'security' => new SecurityRequirements([
234+ []
235+ ]
236+ ...
237+ ]);
238+ ```
239+
240+ ``` yaml
241+ ...
242+ security :
243+ - {}
244+ ...
245+ ```
246+
247+ Write security for multiple authentication:
248+
249+ ``` php
250+ $openapi = new OpenApi([
251+ ...
252+ 'components' => new Components([
253+ 'securitySchemes' => [
254+ 'BearerAuth' => new SecurityScheme([
255+ 'type' => 'http',
256+ 'scheme' => 'bearer',
257+ ]),
258+ 'BasicAuth' => new SecurityScheme([
259+ 'type' => 'http',
260+ 'scheme' => 'basic',
261+ ]),
262+ 'ApiKeyAuth' => new SecurityScheme([
263+ 'type' => 'apiKey',
264+ 'name' => 'X-API-Key',
265+ 'in' => 'header'
266+ ])
267+ ],
268+ ]),
269+ 'security' => new SecurityRequirements([
270+ [
271+ 'BearerAuth' => new SecurityRequirement([]),
272+ 'BasicAuth' => new SecurityRequirement([])
273+ ],
274+ [
275+ 'ApiKeyAuth' => new SecurityRequirement([])
276+ ]
277+ ]),
278+ ...
279+ ]);
280+ ```
281+
282+ ``` yaml
283+ security :
284+ -
285+ BearerAuth : []
286+ BasicAuth : []
287+ -
288+ ApiKeyAuth : []
289+
290+ ```
291+
292+ Write single authentication (note that both below case will yield same output):
293+
294+ ``` php
295+ $openapi = new OpenApi([
296+ ...
297+ 'components' => new Components([
298+ 'securitySchemes' => [
299+ 'BearerAuth' => new SecurityScheme([
300+ 'type' => 'http',
301+ 'scheme' => 'bearer',
302+ ])
303+ ],
304+ ]),
305+ 'security' => new SecurityRequirements([
306+ 'BearerAuth' => new SecurityRequirement([])
307+ ]),
308+ ...
309+ ]);
310+ ```
311+
312+ ``` php
313+ $openapi = new OpenApi([
314+ ...
315+ 'components' => new Components([
316+ 'securitySchemes' => [
317+ 'BearerAuth' => new SecurityScheme([
318+ 'type' => 'http',
319+ 'scheme' => 'bearer',
320+ ])
321+ ],
322+ ]),
323+ 'security' => new SecurityRequirements([
324+ [
325+ 'BearerAuth' => new SecurityRequirement([])
326+ ]
327+ ]),
328+ ...
329+ ]);
330+ ```
331+
332+ ``` yaml
333+ security :
334+ -
335+ BearerAuth : []
336+ ` ` `
337+
228338### Reading API Description Files and Resolving References
229339
230340In the above we have passed the raw JSON or YAML data to the Reader. In order to be able to resolve
0 commit comments