Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: document endpoint tagged Unstable #4118

Merged
merged 23 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6c4033a
chore: document endpoint tagged Unstable
andreas-unleash Jun 29, 2023
ae66b36
Update src/lib/openapi/endpoint-descriptions.ts
andreas-unleash Jun 29, 2023
ac75b78
Update src/lib/openapi/endpoint-descriptions.ts
andreas-unleash Jun 29, 2023
7b40438
Update src/lib/openapi/endpoint-descriptions.ts
andreas-unleash Jun 29, 2023
6d580cd
Update src/lib/openapi/endpoint-descriptions.ts
andreas-unleash Jun 29, 2023
a9119c3
Update src/lib/openapi/endpoint-descriptions.ts
andreas-unleash Jun 29, 2023
fa131f4
Update src/lib/openapi/endpoint-descriptions.ts
andreas-unleash Jun 29, 2023
f24d930
chore: document schemas
andreas-unleash Jun 29, 2023
bbc1285
Merge remote-tracking branch 'origin/chore/open_api_unstable' into ch…
andreas-unleash Jun 29, 2023
7bd2950
chore: document schemas tagged Unstable
andreas-unleash Jun 30, 2023
e82f165
Merge branch 'main' into chore/open_api_unstable
andreas-unleash Jun 30, 2023
cd140c4
Update src/lib/openapi/spec/import-toggles-validate-schema.ts
andreas-unleash Jun 30, 2023
807593a
Update src/lib/openapi/spec/export-result-schema.ts
andreas-unleash Jun 30, 2023
d593337
Update src/lib/openapi/spec/import-toggles-schema.ts
andreas-unleash Jun 30, 2023
68ff640
Merge branch 'main' into chore/open_api_unstable
andreas-unleash Jun 30, 2023
eb136c0
chore: document schemas tagged Unstable
andreas-unleash Jun 30, 2023
2a33dc5
openapi: make meta schema tests happy
thomasheartman Jul 4, 2023
3dbdedd
chore: update snapshot
thomasheartman Jul 4, 2023
923b82c
openapi: fix example value
thomasheartman Jul 4, 2023
fefdc26
chore: add missing example
thomasheartman Jul 4, 2023
e0f046e
chore: remove dev statement
thomasheartman Jul 4, 2023
66e131e
chore: remove log
thomasheartman Jul 4, 2023
5c5bd99
chore: update snapshot
thomasheartman Jul 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/lib/features/export-import-toggles/export-import-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import {
emptyResponse,
ExportQuerySchema,
exportResultSchema,
getStandardResponses,
ImportTogglesSchema,
importTogglesValidateSchema,
} from '../../openapi';
import { IAuthRequest } from '../../routes/unleash-types';
import { extractUsername } from '../../util';
import { BadDataError, InvalidOperationError } from '../../error';
import ApiUser from '../../types/api-user';
import { endpointDescriptions } from '../../openapi/endpoint-descriptions';

class ExportImportController extends Controller {
private logger: Logger;
Expand Down Expand Up @@ -65,12 +67,14 @@ class ExportImportController extends Controller {
handler: this.export,
middleware: [
this.openApiService.validPath({
tags: ['Unstable'],
tags: ['Import/Export'],
operationId: 'exportFeatures',
requestBody: createRequestSchema('exportQuerySchema'),
responses: {
200: createResponseSchema('exportResultSchema'),
...getStandardResponses(404),
},
...endpointDescriptions.admin.export,
}),
],
});
Expand All @@ -81,17 +85,16 @@ class ExportImportController extends Controller {
handler: this.validateImport,
middleware: [
openApiService.validPath({
summary:
'Validate import of feature toggles for an environment in the project',
description: `Unleash toggles exported from a different instance can be imported into a new project and environment`,
tags: ['Unstable'],
tags: ['Import/Export'],
operationId: 'validateImport',
requestBody: createRequestSchema('importTogglesSchema'),
responses: {
200: createResponseSchema(
'importTogglesValidateSchema',
),
...getStandardResponses(404),
},
...endpointDescriptions.admin.validateImport,
}),
],
});
Expand All @@ -102,15 +105,14 @@ class ExportImportController extends Controller {
handler: this.importData,
middleware: [
openApiService.validPath({
summary:
'Import feature toggles for an environment in the project',
description: `Unleash toggles exported from a different instance can be imported into a new project and environment`,
tags: ['Unstable'],
tags: ['Import/Export'],
operationId: 'importToggles',
requestBody: createRequestSchema('importTogglesSchema'),
responses: {
200: emptyResponse,
...getStandardResponses(404),
},
...endpointDescriptions.admin.import,
}),
],
});
Expand Down
13 changes: 13 additions & 0 deletions src/lib/openapi/endpoint-descriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,18 @@ export const endpointDescriptions = {
summary:
'Batch evaluate an Unleash context against a set of environments and projects.',
},
export: {
description:
"Exports all features listed in the `features` property from the environment specified in the request body. If set to `true`, the `downloadFile` property will let you download a file with the exported data. Otherwise, the export data is returned directly as JSON. Refer to the documentation for more information about [Unleash's export functionality](https://docs.getunleash.io/reference/deploy/environment-import-export#export).",
summary: 'Export feature toggles from an environment',
},
validateImport: {
summary: 'Validate feature import data',
description: `Validates a feature toggle data set. Checks whether the data can be imported into the specified project and environment. The returned value is an object that contains errors, warnings, and permissions required to perform the import, as described in the [import documentation](https://docs.getunleash.io/reference/deploy/environment-import-export#import).`,
},
import: {
summary: 'Import feature toggles',
description: `[Import feature toggles](https://docs.getunleash.io/reference/deploy/environment-import-export#import) into a specific project and environment.`,
},
},
} as const;
6 changes: 6 additions & 0 deletions src/lib/openapi/spec/export-query-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ export const exportQuerySchema = {
properties: {
environment: {
type: 'string',
example: 'development',
description: 'The environment to export from',
},
downloadFile: {
type: 'boolean',
example: 'development',
description: 'Whether to return a downloadable file',
},
},
oneOf: [
Expand All @@ -19,6 +23,7 @@ export const exportQuerySchema = {
properties: {
features: {
type: 'array',
example: ['MyAwesomeFeature'],
items: {
type: 'string',
minLength: 1,
Expand All @@ -32,6 +37,7 @@ export const exportQuerySchema = {
properties: {
tag: {
type: 'string',
example: 'release',
description:
'Selects features to export by tag. Takes precedence over the features field.',
},
Expand Down
3 changes: 3 additions & 0 deletions src/lib/openapi/spec/export-result-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const exportResultSchema = {
$id: '#/components/schemas/exportResultSchema',
type: 'object',
additionalProperties: false,
description:
'The result of the export operation, providing you with the feature toggle definitions, strategy definitions and the rest of the elements relevant to the features (tags, environments etc.)',
summary: 'The export result schema',
andreas-unleash marked this conversation as resolved.
Show resolved Hide resolved
required: ['features', 'featureStrategies', 'tagTypes'],
properties: {
features: {
Expand Down
9 changes: 9 additions & 0 deletions src/lib/openapi/spec/import-toggles-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ export const importTogglesSchema = {
type: 'object',
required: ['project', 'environment', 'data'],
additionalProperties: false,
summary: 'Import toggles schema',
andreas-unleash marked this conversation as resolved.
Show resolved Hide resolved
description:
'The result of the export operation for a project and environment, used at import',
properties: {
project: {
type: 'string',
example: 'My awesome project',
description:
'The exported [project](https://docs.getunleash.io/reference/projects)',
},
environment: {
type: 'string',
example: 'development',
description:
'The exported [environment](https://docs.getunleash.io/reference/environments)',
},
data: {
$ref: '#/components/schemas/exportResultSchema',
Expand Down
3 changes: 3 additions & 0 deletions src/lib/openapi/spec/import-toggles-validate-item-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ export const importTogglesValidateItemSchema = {
properties: {
message: {
type: 'string',
description: 'The validation error message',
thomasheartman marked this conversation as resolved.
Show resolved Hide resolved
},
affectedItems: {
type: 'array',
description: 'The items affected by this error message ',
example: ['some-feature-a', 'some-feature-b'],
items: {
type: 'string',
},
Expand Down
2 changes: 2 additions & 0 deletions src/lib/openapi/spec/import-toggles-validate-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const importTogglesValidateSchema = {
type: 'object',
required: ['errors', 'warnings'],
additionalProperties: false,
summary: 'Import toggles validation result schema',
andreas-unleash marked this conversation as resolved.
Show resolved Hide resolved
description: 'The result of toggle validation after import',
properties: {
errors: {
type: 'array',
Expand Down
5 changes: 5 additions & 0 deletions src/lib/openapi/util/openapi-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ const OPENAPI_TAGS = [
name: 'Telemetry',
description: 'API for information about telemetry collection',
},
{
name: 'Notifications',
description:
'API for managing [notifications](https://docs.getunleash.io/reference/notifications).',
},
] as const;

// make the export mutable, so it can be used in a schema
Expand Down