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

Inline endpoint descriptions #4145

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ 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 @@ -74,7 +73,9 @@ class ExportImportController extends Controller {
200: createResponseSchema('exportResultSchema'),
...getStandardResponses(404),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't provide a key you may probably get 401 - I'd test it in the openapi UI

},
...endpointDescriptions.admin.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).",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also export by tags, not just by features

summary: 'Export feature toggles from an environment',
}),
],
});
Expand All @@ -94,7 +95,8 @@ class ExportImportController extends Controller {
),
...getStandardResponses(404),
},
...endpointDescriptions.admin.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).`,
}),
],
});
Expand All @@ -112,7 +114,8 @@ class ExportImportController extends Controller {
200: emptyResponse,
...getStandardResponses(404),
},
...endpointDescriptions.admin.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.`,
}),
],
});
Expand Down
11 changes: 8 additions & 3 deletions src/lib/features/playground/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { NONE } from '../../types/permissions';
import Controller from '../../routes/controller';
import { OpenApiService } from '../../services/openapi-service';
import { createResponseSchema } from '../../openapi/util/create-response-schema';
import { endpointDescriptions } from '../../openapi/endpoint-descriptions';
import { getStandardResponses } from '../../openapi/util/standard-responses';
import { createRequestSchema } from '../../openapi/util/create-request-schema';
import {
Expand Down Expand Up @@ -55,7 +54,10 @@ export default class PlaygroundController extends Controller {
200: createResponseSchema('playgroundResponseSchema'),
},
requestBody: createRequestSchema('playgroundRequestSchema'),
...endpointDescriptions.admin.playground,
description:
'Use the provided `context`, `environment`, and `projects` to evaluate toggles on this Unleash instance. Returns a list of all toggles that match the parameters and what they evaluate to. The response also contains the input parameters that were provided.',
summary:
'Evaluate an Unleash context against a set of environments and projects.',
}),
],
});
Expand All @@ -78,7 +80,10 @@ export default class PlaygroundController extends Controller {
requestBody: createRequestSchema(
'advancedPlaygroundRequestSchema',
),
...endpointDescriptions.admin.advancedPlayground,
description:
'Use the provided `context`, `environments`, and `projects` to evaluate toggles on this Unleash instance. You can use comma-separated values to provide multiple values to each context field. Returns a combinatorial list of all toggles that match the parameters and what they evaluate to. The response also contains the input parameters that were provided.',
summary:
'Batch evaluate an Unleash context against a set of environments and projects.',
}),
],
});
Expand Down
40 changes: 0 additions & 40 deletions src/lib/openapi/endpoint-descriptions.ts

This file was deleted.

12 changes: 8 additions & 4 deletions src/lib/routes/admin-api/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Controller from '../controller';
import { anonymiseKeys } from '../../util/anonymise';
import { OpenApiService } from '../../services/openapi-service';
import { createResponseSchema } from '../../openapi/util/create-response-schema';
import { endpointDescriptions } from '../../openapi/endpoint-descriptions';
import {
eventsSchema,
EventsSchema,
Expand Down Expand Up @@ -67,8 +66,10 @@ export default class EventController extends Controller {
in: 'query',
},
],

...endpointDescriptions.admin.events,
description:
'Returns **the last 100** events from the Unleash instance when called without a query parameter. When called with a `project` parameter, returns **all events** for the specified project.\n\nIf the provided project does not exist, the list of events will be empty.',
summary:
'Get the most recent events from the Unleash instance or all events related to a project.',
}),
],
});
Expand All @@ -86,7 +87,10 @@ export default class EventController extends Controller {
...getStandardResponses(401),
200: createResponseSchema('featureEventsSchema'),
},
...endpointDescriptions.admin.eventsPerFeature,
description:
'Returns all events related to the specified feature toggle. If the feature toggle does not exist, the list of events will be empty.',
summary:
'Get all events related to a specific feature toggle.',
}),
],
});
Expand Down