-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathindex.ts
63 lines (61 loc) · 2 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type { OpenAPIV3 } from 'openapi-types';
import { apiRequestSchema } from './spec/api-request-schema';
import { featureSchema } from './spec/feature-schema';
import { featuresSchema } from './spec/features-schema';
import { lookupTogglesSchema } from './spec/lookup-toggles-schema';
import { registerClientSchema } from './spec/register-client-schema';
import { registerMetricsSchema } from './spec/register-metrics-schema';
import { unleashContextSchema } from './spec/unleash-context-schema';
import { variantSchema } from './spec/variant-schema';
// Create the base OpenAPI schema, with everything except paths.
export const createOpenApiSchema = (
serverUrl?: string,
clientKeysHeaderName: string = 'Authorization',
): Omit<OpenAPIV3.Document, 'paths'> => ({
openapi: '3.0.3',
servers: serverUrl ? [{ url: serverUrl }] : [],
info: {
title: 'Unleash Proxy API',
version: process.env.npm_package_version || '',
},
security: [
{
apiKey: [],
},
],
tags: [
{
name: 'Proxy client',
description:
'Feature toggle endpoints intended to be consumed by proxy clients.',
},
{
name: 'Server-side client',
description:
'Feature toggle endpoints related to and intended to be consumed by server-side clients and other proxies.',
},
{
name: 'Operational',
description: 'Endpoints related to operating the Unleash proxy.',
},
],
components: {
securitySchemes: {
apiKey: {
type: 'apiKey',
in: 'header',
name: clientKeysHeaderName,
},
},
schemas: {
apiRequestSchema,
featureSchema,
featuresSchema,
lookupTogglesSchema,
registerMetricsSchema,
registerClientSchema,
unleashContextSchema,
variantSchema,
},
},
});