From ece96eb933807b2f98f6b3422abd0cb2dd0f720f Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Fri, 22 Jul 2022 11:06:53 +0200 Subject: [PATCH] Refactor: remove unused types --- .../openapi/spec/export-parameters-schema.ts | 118 +----------------- src/lib/routes/admin-api/state.ts | 5 +- 2 files changed, 8 insertions(+), 115 deletions(-) diff --git a/src/lib/openapi/spec/export-parameters-schema.ts b/src/lib/openapi/spec/export-parameters-schema.ts index 8ec54a5f32..d6de36a32a 100644 --- a/src/lib/openapi/spec/export-parameters-schema.ts +++ b/src/lib/openapi/spec/export-parameters-schema.ts @@ -1,7 +1,6 @@ import { FromSchema } from 'json-schema-to-ts'; import { OpenAPIV3 } from 'openapi-types'; import { createQueryParameters } from '../util/query-parameters'; -import { Parameters } from '../util/query-parameters'; const exportParameters = { format: { @@ -53,8 +52,9 @@ type Mutable = { [Property in keyof ExportParams]: { type: ExportParams[Property]['type'] }; }; -const p = { - $id: 'th', +// this schema is here only to generate types +const exportQueryParametersSchema = { + $id: '#/components/schemas/exportQueryParameters', type: 'object', properties: createQueryParameters(exportParameters).reduce( (acc, next: OpenAPIV3.ParameterObject) => ({ @@ -67,114 +67,8 @@ const p = { ) as Mutable, } as const; -export type ExpType = FromSchema; +export type ExportQueryParameters = FromSchema< + typeof exportQueryParametersSchema +>; export const exportQueryParameters = createQueryParameters(exportParameters); - -const s = { - $id: '#/components/schemas/exportParametersSchema2', - parameters: [ - { - name: 'format', - description: - 'Desired export format. Must be either `json` or `yaml`.', - schema: { - type: 'string', - enum: ['json', 'yaml'], - default: 'json', - }, - in: 'query', - }, - { - name: 'download', - description: - 'Whether exported data should be downloaded as a file.', - schema: { - type: 'boolean', - default: false, - }, - in: 'query', - }, - { - name: 'strategies', - description: - 'Whether strategies should be included in the exported data.', - schema: { - type: 'boolean', - default: true, - }, - in: 'query', - }, - { - name: 'featureToggles', - description: - 'Whether feature toggles should be included in the exported data.', - schema: { - type: 'boolean', - default: true, - }, - in: 'query', - }, - { - name: 'projects', - description: - 'Whether projects should be included in the exported data.', - schema: { - type: 'boolean', - default: true, - }, - in: 'query', - }, - { - name: 'tags', - description: - 'Whether tag types, tags, and feature_tags should be included in the exported data.', - schema: { - type: 'boolean', - default: true, - }, - in: 'query', - }, - { - name: 'environments', - description: - 'Whether environments should be included in the exported data.', - schema: { - type: 'boolean', - default: true, - }, - in: 'query', - }, - ], -} as const; - -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; diff --git a/src/lib/routes/admin-api/state.ts b/src/lib/routes/admin-api/state.ts index 324644a29c..b8cd09dec9 100644 --- a/src/lib/routes/admin-api/state.ts +++ b/src/lib/routes/admin-api/state.ts @@ -16,8 +16,7 @@ import { createRequestSchema } from '../../openapi/util/create-request-schema'; import { createResponseSchema } from '../../openapi/util/create-response-schema'; import { exportQueryParameters, - ExportParametersSchema, - ExpType, + ExportQueryParameters, } from '../../openapi/spec/export-parameters-schema'; import { emptyResponse } from '../../openapi/util/standard-responses'; @@ -114,7 +113,7 @@ class StateController extends Controller { } async export( - req: Request, + req: Request, res: Response, ): Promise { const { format } = req.query;