mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-12 01:17:04 +02:00
Feat: add query params to state
This commit is contained in:
parent
2594f0051a
commit
c9ce6a6067
@ -1,31 +1,47 @@
|
|||||||
import { FromSchema } from 'json-schema-to-ts';
|
import { FromSchema } from 'json-schema-to-ts';
|
||||||
|
import { Parameters } from '../util/request-parameters';
|
||||||
|
|
||||||
const exportParameters = {
|
export const exportParameters: Parameters = {
|
||||||
format: {
|
format: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
enum: ['json', 'yaml'],
|
enum: ['json', 'yaml'],
|
||||||
default: 'json',
|
default: 'json',
|
||||||
description: '',
|
description: 'Desired export format. Must be either `json` or `yaml`.',
|
||||||
},
|
},
|
||||||
download: {
|
download: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: 'false',
|
default: false,
|
||||||
description: '',
|
description: 'Whether exported data should be downloaded as a file.',
|
||||||
},
|
},
|
||||||
strategies: {
|
strategies: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description:
|
||||||
|
'Whether strategies should be included in the exported data.',
|
||||||
},
|
},
|
||||||
featureToggles: {
|
featureToggles: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description:
|
||||||
|
'Whether feature toggles should be included in the exported data.',
|
||||||
},
|
},
|
||||||
projects: {
|
projects: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description:
|
||||||
|
'Whether projects should be included in the exported data.',
|
||||||
},
|
},
|
||||||
tags: {
|
tags: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description:
|
||||||
|
'Whether tag types, tags, and feature_tags should be included in the exported data.',
|
||||||
},
|
},
|
||||||
environments: {
|
environments: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description:
|
||||||
|
'Whether environments should be included in the exported data.',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ describe('request parameter utils', () => {
|
|||||||
result.description === details.description &&
|
result.description === details.description &&
|
||||||
result.example === details.example &&
|
result.example === details.example &&
|
||||||
schema.enum === details.enum &&
|
schema.enum === details.enum &&
|
||||||
schema.default === details.default
|
schema.default === details.default &&
|
||||||
|
result.required === details.required
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -5,6 +5,7 @@ export type ParameterType = OpenAPIV3.NonArraySchemaObjectType;
|
|||||||
export type ParameterDetails<U> = {
|
export type ParameterDetails<U> = {
|
||||||
description: string;
|
description: string;
|
||||||
type: ParameterType;
|
type: ParameterType;
|
||||||
|
required?: boolean;
|
||||||
default?: U;
|
default?: U;
|
||||||
enum?: [U, ...U[]];
|
enum?: [U, ...U[]];
|
||||||
example?: U;
|
example?: U;
|
||||||
@ -21,6 +22,7 @@ export const toParamObject = (
|
|||||||
name,
|
name,
|
||||||
example: details.example,
|
example: details.example,
|
||||||
description: details.description,
|
description: details.description,
|
||||||
|
required: details.required,
|
||||||
schema: {
|
schema: {
|
||||||
type: details.type,
|
type: details.type,
|
||||||
enum: details.enum,
|
enum: details.enum,
|
||||||
|
@ -15,11 +15,11 @@ import { OpenApiService } from '../../services/openapi-service';
|
|||||||
import { createRequestSchema } from '../../openapi/util/create-request-schema';
|
import { createRequestSchema } from '../../openapi/util/create-request-schema';
|
||||||
import { createResponseSchema } from '../../openapi/util/create-response-schema';
|
import { createResponseSchema } from '../../openapi/util/create-response-schema';
|
||||||
import {
|
import {
|
||||||
exportParametersSchema,
|
exportParameters,
|
||||||
ExportParametersSchema,
|
ExportParametersSchema,
|
||||||
} from '../../openapi/spec/export-parameters-schema';
|
} from '../../openapi/spec/export-parameters-schema';
|
||||||
import { emptyResponse } from '../../openapi/util/standard-responses';
|
import { emptyResponse } from '../../openapi/util/standard-responses';
|
||||||
import { createRequestParameters } from 'lib/openapi/util/request-parameters';
|
import { createRequestParameters } from '../../openapi/util/request-parameters';
|
||||||
|
|
||||||
const upload = multer({ limits: { fileSize: 5242880 } });
|
const upload = multer({ limits: { fileSize: 5242880 } });
|
||||||
const paramToBool = (param, def) => {
|
const paramToBool = (param, def) => {
|
||||||
@ -79,7 +79,7 @@ class StateController extends Controller {
|
|||||||
responses: {
|
responses: {
|
||||||
200: createResponseSchema('stateSchema'),
|
200: createResponseSchema('stateSchema'),
|
||||||
},
|
},
|
||||||
// parameters: createRequestParameters(exportParametersSchema),
|
parameters: createRequestParameters(exportParameters),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user