2022-04-25 14:17:59 +02:00
|
|
|
import { OpenAPIV3 } from 'openapi-types';
|
2022-05-04 15:16:18 +02:00
|
|
|
import { constraintSchema } from './spec/constraint-schema';
|
|
|
|
import { createFeatureSchema } from './spec/create-feature-schema';
|
|
|
|
import { createStrategySchema } from './spec/create-strategy-schema';
|
2022-04-25 14:17:59 +02:00
|
|
|
import { featureSchema } from './spec/feature-schema';
|
2022-05-04 15:16:18 +02:00
|
|
|
import { featuresSchema } from './spec/features-schema';
|
|
|
|
import { overrideSchema } from './spec/override-schema';
|
|
|
|
import { parametersSchema } from './spec/parameters-schema';
|
2022-04-25 14:17:59 +02:00
|
|
|
import { strategySchema } from './spec/strategy-schema';
|
|
|
|
import { variantSchema } from './spec/variant-schema';
|
|
|
|
|
|
|
|
export const createOpenApiSchema = (
|
|
|
|
serverUrl?: string,
|
|
|
|
): Omit<OpenAPIV3.Document, 'paths'> => {
|
|
|
|
return {
|
|
|
|
openapi: '3.0.3',
|
|
|
|
servers: serverUrl ? [{ url: serverUrl }] : [],
|
|
|
|
info: {
|
|
|
|
title: 'Unleash API',
|
|
|
|
version: process.env.npm_package_version,
|
|
|
|
},
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
apiKey: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
components: {
|
|
|
|
securitySchemes: {
|
|
|
|
apiKey: {
|
|
|
|
type: 'apiKey',
|
|
|
|
in: 'header',
|
|
|
|
name: 'Authorization',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
schemas: {
|
2022-05-04 15:16:18 +02:00
|
|
|
constraintSchema,
|
2022-04-25 14:17:59 +02:00
|
|
|
createFeatureSchema,
|
2022-05-04 15:16:18 +02:00
|
|
|
createStrategySchema,
|
2022-04-25 14:17:59 +02:00
|
|
|
featureSchema,
|
2022-05-04 15:16:18 +02:00
|
|
|
featuresSchema,
|
|
|
|
overrideSchema,
|
|
|
|
parametersSchema,
|
2022-04-25 14:17:59 +02:00
|
|
|
strategySchema,
|
|
|
|
variantSchema,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|