Task/open api state (#1738)

* task: add open api to import/export
This commit is contained in:
Christopher Kolstad
2022-06-22 09:09:49 +02:00
committed by GitHub
parent 5bae11a3fb
commit 18c720f4e9
8 changed files with 495 additions and 4 deletions
+10
View File
@@ -52,6 +52,11 @@ import { versionSchema } from './spec/version-schema';
import { applicationSchema } from './spec/application-schema';
import { applicationsSchema } from './spec/applications-schema';
import { tagWithVersionSchema } from './spec/tag-with-version-schema';
import { featureStrategySegmentSchema } from './spec/feature-strategy-segment-schema';
import { segmentSchema } from './spec/segment-schema';
import { stateSchema } from './spec/state-schema';
import { featureTagSchema } from './spec/feature-tag-schema';
import { exportParametersSchema } from './spec/export-parameters-schema';
// All schemas in `openapi/spec` should be listed here.
export const schemas = {
@@ -68,9 +73,12 @@ export const schemas = {
createStrategySchema,
environmentSchema,
environmentsSchema,
exportParametersSchema,
featureEnvironmentSchema,
featureSchema,
featureStrategySchema,
featureStrategySegmentSchema,
featureTagSchema,
featureTypeSchema,
featureTypesSchema,
featureVariantsSchema,
@@ -88,8 +96,10 @@ export const schemas = {
projectEnvironmentSchema,
projectSchema,
projectsSchema,
segmentSchema,
sortOrderSchema,
splashSchema,
stateSchema,
strategySchema,
tagSchema,
tagWithVersionSchema,
@@ -0,0 +1,32 @@
import { FromSchema } from 'json-schema-to-ts';
export const exportParametersSchema = {
$id: '#/components/schemas/exportParametersSchema',
type: 'object',
properties: {
format: {
type: 'string',
},
download: {
type: 'boolean',
},
strategies: {
type: 'boolean',
},
featureToggles: {
type: 'boolean',
},
projects: {
type: 'boolean',
},
tags: {
type: 'boolean',
},
environments: {
type: 'boolean',
},
},
components: {},
} as const;
export type ExportParametersSchema = FromSchema<typeof exportParametersSchema>;
@@ -0,0 +1,21 @@
import { FromSchema } from 'json-schema-to-ts';
export const featureStrategySegmentSchema = {
$id: '#/components/schemas/featureStrategySegmentSchema',
type: 'object',
additionalProperties: false,
required: ['segmentId', 'featureStrategyId'],
properties: {
segmentId: {
type: 'integer',
},
featureStrategyId: {
type: 'string',
},
},
components: {},
} as const;
export type FeatureStrategySegmentSchema = FromSchema<
typeof featureStrategySegmentSchema
>;
@@ -0,0 +1,28 @@
import { FromSchema } from 'json-schema-to-ts';
export const featureTagSchema = {
$id: '#/components/schemas/featureTagSchema',
type: 'object',
additionalProperties: false,
required: ['featureName', 'tagValue'],
properties: {
featureName: {
type: 'string',
},
tagType: {
type: 'string',
},
tagValue: {
type: 'string',
},
type: {
type: 'string',
},
value: {
type: 'string',
},
},
components: {},
} as const;
export type FeatureTagSchema = FromSchema<typeof featureTagSchema>;
+30
View File
@@ -0,0 +1,30 @@
import { FromSchema } from 'json-schema-to-ts';
import { constraintSchema } from './constraint-schema';
export const segmentSchema = {
$id: '#/components/schemas/segmentSchema',
type: 'object',
additionalProperties: false,
required: ['name', 'constraints'],
properties: {
name: {
type: 'string',
},
description: {
type: 'string',
},
constraints: {
type: 'array',
items: {
$ref: '#/components/schemas/constraintSchema',
},
},
},
components: {
schemas: {
constraintSchema,
},
},
} as const;
export type SegmentSchema = FromSchema<typeof segmentSchema>;
+107
View File
@@ -0,0 +1,107 @@
import { FromSchema } from 'json-schema-to-ts';
import { featureSchema } from './feature-schema';
import { strategySchema } from './strategy-schema';
import { tagSchema } from './tag-schema';
import { tagTypeSchema } from './tag-type-schema';
import { featureTagSchema } from './feature-tag-schema';
import { projectSchema } from './project-schema';
import { featureStrategySchema } from './feature-strategy-schema';
import { featureEnvironmentSchema } from './feature-environment-schema';
import { environmentSchema } from './environment-schema';
import { segmentSchema } from './segment-schema';
import { featureStrategySegmentSchema } from './feature-strategy-segment-schema';
export const stateSchema = {
$id: '#/components/schemas/stateSchema',
type: 'object',
additionalProperties: true,
required: ['version'],
properties: {
version: {
type: 'integer',
},
features: {
type: 'array',
items: {
$ref: '#/components/schemas/featureSchema',
},
},
strategies: {
type: 'array',
items: {
$ref: '#/components/schemas/strategySchema',
},
},
tags: {
type: 'array',
items: {
$ref: '#/components/schemas/tagSchema',
},
},
tagTypes: {
type: 'array',
items: {
$ref: '#/components/schemas/tagTypeSchema',
},
},
featureTags: {
type: 'array',
items: {
$ref: '#/components/schemas/featureTagSchema',
},
},
projects: {
type: 'array',
items: {
$ref: '#/components/schemas/projectSchema',
},
},
featureStrategies: {
type: 'array',
items: {
$ref: '#/components/schemas/featureStrategySchema',
},
},
featureEnvironments: {
type: 'array',
items: {
$ref: '#/components/schemas/featureEnvironmentSchema',
},
},
environments: {
type: 'array',
items: {
$ref: '#/components/schemas/environmentSchema',
},
},
segments: {
type: 'array',
items: {
$ref: '#/components/schemas/segmentSchema',
},
},
featureStrategySegments: {
type: 'array',
items: {
$ref: '#/components/schemas/featureStrategySegmentSchema',
},
},
},
components: {
schemas: {
featureSchema,
strategySchema,
tagSchema,
tagTypeSchema,
featureTagSchema,
projectSchema,
featureStrategySchema,
featureEnvironmentSchema,
environmentSchema,
segmentSchema,
featureStrategySegmentSchema,
},
},
} as const;
export type StateSchema = FromSchema<typeof stateSchema>;