1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/openapi/endpoint-descriptions.ts

22 lines
1.2 KiB
TypeScript
Raw Normal View History

export const endpointDescriptions = {
admin: {
events: {
description:
fix: Fix broken OpenAPI (#2379) ## What This change removes the use of double quotes in the 'addPublicSignupTokenUser' endpoint summary. It also changes the original summary to a description and adds a new, shorter summary. ## Why The OpenAPI / docusaurus integration errors out (refer to [this failed build](https://github.com/Unleash/unleash/actions/runs/3434792557/jobs/5726445104)) if the frontmatter contains invalid characters. In this case, it's because the automatic sidebar label contains double quotes, which it interprets as a new key having been declared: ``` Error: Error while parsing Markdown front matter. This can happen if you use special characters in front matter values (try using double quotes around that value). Error: Loading of version failed for version current Error: Unable to build website for locale en. Error: YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key at line 4, column 12: description: "Create a user with the 'viewe ... ^ ``` For some reason, I cannot reproduce this error locally. Instead, the generation goes as expected. --- Regarding using description instead of summary: summaries should be very short and sweet, especially because they're also used in the generated sidebar. Descriptions can be a bit wordier, so I added a shorter summary for going forward. ## Generated output This is what the old configuration would generate. Notice the `sidedar_label` key on line 2: ```md --- id: add-public-signup-token-user sidebar_label: Create a user with the "viewer" root role and link them to a signup token hide_title: true hide_table_of_contents: true api: {'tags': ['Public signup tokens'], 'operationId': 'addPublicSignupTokenUser', 'requestBody': {'description': 'createInvitedUserSchema', 'required': true, 'content': {'application/json': {'schema': {'type': 'object', 'additionalProperties': false, 'required': ['email', 'name', 'password'], 'properties': {'username': { 'type': 'string' }, 'email': { 'type': 'string' }, 'name': { 'type': 'string' }, 'password': { 'type': 'string' },},},},},}, 'responses': {'200': {'description': 'userSchema', 'content': {'application/json': {'schema': {'type': 'object', 'additionalProperties': false, 'required': ['id'], 'properties': {'id': {'type': 'number',}, 'isAPI': {'type': 'boolean',}, 'name': {'type': 'string',}, 'email': {'type': 'string',}, 'username': {'type': 'string',}, 'imageUrl': {'type': 'string',}, 'inviteLink': {'type': 'string',}, 'loginAttempts': {'type': 'number',}, 'emailSent': {'type': 'boolean',}, 'rootRole': {'type': 'number',}, 'seenAt': {'type': 'string', 'format': 'date-time', 'nullable': true,}, 'createdAt': {'type': 'string', 'format': 'date-time',},},},},},}, '400': {'description': 'The request data does not match what we expect.',}, '409': {'description': 'The provided resource can not be created or updated because it would conflict with the current state of the resource or with an already existing resource, respectively.',},}, 'parameters': [{'name': 'token', 'in': 'path', 'required': true, 'schema': { 'type': 'string' },},], 'description': 'Create a user with the "viewer" root role and link them to a signup token', 'method': 'post', 'path': '/invite/{token}/signup', 'servers': [{ 'url': '<your-unleash-url>' }], 'security': [{ 'apiKey': [] }], 'securitySchemes': {'apiKey': {'type': 'apiKey', 'in': 'header', 'name': 'Authorization',},}, 'jsonRequestBodyExample': {'username': 'string', 'email': 'string', 'name': 'string', 'password': 'string',}, 'info': { 'title': 'Unleash API', 'version': '4.17.2' }, 'postman': {'name': 'Create a user with the "viewer" root role and link them to a signup token', 'description': { 'type': 'text/plain' }, 'url': {'path': ['invite', ':token', 'signup'], 'host': ['{{baseUrl}}'], 'query': [], 'variable': [{'disabled': false, 'description': {'content': '(Required) ', 'type': 'text/plain',}, 'type': 'any', 'value': '', 'key': 'token',},],}, 'header': [{ 'key': 'Content-Type', 'value': 'application/json' }, { 'key': 'Accept', 'value': 'application/json' },], 'method': 'POST', 'body': {'mode': 'raw', 'raw': '""', 'options': { 'raw': { 'language': 'json' } }}}} sidebar_class_name: 'post api-method' info_path: docs/reference/api/unleash/unleash-api --- import ApiTabs from "@theme/ApiTabs"; import MimeTabs from "@theme/MimeTabs"; import ParamsItem from "@theme/ParamsItem"; import ResponseSamples from "@theme/ResponseSamples"; import SchemaItem from "@theme/SchemaItem" import SchemaTabs from "@theme/SchemaTabs"; import DiscriminatorTabs from "@theme/DiscriminatorTabs"; import TabItem from "@theme/TabItem"; ## Create a user with the &quot;viewer&quot; root role and link them to a signup token Create a user with the &quot;viewer&quot; root role and link them to a signup token <!-- And much much more! --> ```
2022-11-10 22:55:01 +01:00
'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.',
},
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.',
},
feat: add playground API post endpoint (#1791) * Chore: add unleash-client dependency * Feat: add openapi specs for basic sdk contexts and playground reqs * Feat: add openapi spec for response * Feat: add openAPI entry for playground endpoint * Fix: remove required 'projects' property that doesn't exist * Refactor: add test placeholders for playground api * Chore: improve openAPI description for playground request * Refactor: align example project names * Fix: update openapi snapshot * Fix: summary -> description; example -> examples * Feat: add fast-check and stub out one test. The test doesn't work yet. * Feat: add test and generator for sdk context schema * Feat: add generators and tests for all new schemas * Feat: test that the same input is returned exactly * Feat: add more tests and more schemas * Refactor: clean up tests some * Refactor: simplify url friendliness check * Refactor: fix types for playground request schema generator * Feat: add bad request test * Fix: make parameters the correct shape in generator * Feat: scaffold out tests for service and endpoint Liberal use of @ts-expect-error * Fix: update snapshot with new model * Add missing appName * wip: stub out some extra tests * Feat: model strategies for testing * Feat: model variant payloads better * Refactor: input params for function * Refactor: use email address for user id generation * Chore: update comment * Wip: start stubbing out e2e tests * Refactor: move tests requiring db to e2e file * Fix: make e2e tests run as expected * Fix: make toggle generator test work as expected * Fix: increase timeout for long-running e2e test * Wip: map toggles test * Wip: test movement and cleanup * Refactor: remove `AllowedStrings` in favor of typeof X[number] * Wip: add e2e tests for the service * Wip: tests in progress * Feat: return fuller variant value * Wip: delete redundant test. Both those tests were testing versions of the same thing, so let's delete one of them * Feat: update openAPI snapshot * Feat: hook up the playground service * Feat: fix test cases for e2e api * Refactor: get rid of _one_ 'as unknown as x' cast * Fix: wait for the client to be ready before we pass it back * Fix: weights go to 1000! * Fix: fix some test assertions, add one more test to be sure * Wip: add some test parameters to hopefully avoid timeouts * Fix: don't init the client if there are no toggles If you don't provide it with any toggles to bootstrap, then the client will never be ready. This avoids that. This adds two ways around it because we'll probably get away with a bit less computation if we don't even try to initialize it. However, we also don't want anyone else to make this mistake. * Chore: modify test params * Feat: use the type system to avoid empty lists for initialization * Refactor: make tests simpler * Feat: test basic context values * Feat: test dynamic context values * Fix: make custom context field test more reliable * Feat: use unique arrays for toggles * Feat: make `appName` required in context * Fix: sdk context schema arbitrary: make appName at least 1 char long * Fix: add a minimum length on appName in the context schema * Fix: fix tests that fail due to new requirements * Fix: update a test: remove variant mapping testing * Fix: fix remaining tests * Feat: rename response.toggles -> response.features * Refactor: avoid single-letter predicate variables * Refactor: extract offlineclient into its own file * Refactor: move arbitraries into separate file * Refactor: move playground requests into util function * Fix: remove duplicate declaration of urlFriendlyString * Chore: update comment * Refactor: align on arbitrary generator naming * Feat: Export single strategy arbitrary
2022-07-12 13:01:10 +02:00
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.',
},
},
} as const;