diff --git a/src/lib/openapi/spec/empty-response.ts b/src/lib/openapi/spec/empty-response.ts index 37879aba23..e69de29bb2 100644 --- a/src/lib/openapi/spec/empty-response.ts +++ b/src/lib/openapi/spec/empty-response.ts @@ -1,3 +0,0 @@ -export const emptyResponse = { - description: 'emptyResponse', -}; diff --git a/src/lib/openapi/util/standard-responses.ts b/src/lib/openapi/util/standard-responses.ts index dca0ade3e1..e1fe52c666 100644 --- a/src/lib/openapi/util/standard-responses.ts +++ b/src/lib/openapi/util/standard-responses.ts @@ -1,3 +1,7 @@ +export const emptyResponse = { + description: 'emptyResponse', +}; + export const unauthorizedResponse = { description: 'Authorization information is missing or invalid. Provide a valid API token as the `authorization` header, e.g. `authorization:*.*.my-admin-token`.', diff --git a/src/lib/routes/admin-api/addon.ts b/src/lib/routes/admin-api/addon.ts index 724b976d8f..946c4bb0eb 100644 --- a/src/lib/routes/admin-api/addon.ts +++ b/src/lib/routes/admin-api/addon.ts @@ -14,10 +14,10 @@ import { import { IAuthRequest } from '../unleash-types'; import { createRequestSchema, createResponseSchema } from '../../openapi'; import { OpenApiService } from '../../services/openapi-service'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { AddonSchema, addonSchema } from '../../openapi/spec/addon-schema'; import { serializeDates } from '../../types/serialize-dates'; import { AddonsSchema, addonsSchema } from '../../openapi/spec/addons-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; type AddonServices = Pick; diff --git a/src/lib/routes/admin-api/api-token.ts b/src/lib/routes/admin-api/api-token.ts index 1a6a04d06b..db35039e03 100644 --- a/src/lib/routes/admin-api/api-token.ts +++ b/src/lib/routes/admin-api/api-token.ts @@ -28,8 +28,8 @@ import { apiTokenSchema, ApiTokenSchema, } from '../../openapi/spec/api-token-schema'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { UpdateApiTokenSchema } from '../../openapi/spec/update-api-token-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; interface TokenParam { token: string; diff --git a/src/lib/routes/admin-api/archive.ts b/src/lib/routes/admin-api/archive.ts index e698ba4784..c717b490c7 100644 --- a/src/lib/routes/admin-api/archive.ts +++ b/src/lib/routes/admin-api/archive.ts @@ -14,7 +14,7 @@ import { import { serializeDates } from '../../types/serialize-dates'; import { OpenApiService } from '../../services/openapi-service'; import { createResponseSchema } from '../../openapi'; -import { emptyResponse } from '../../openapi/spec/empty-response'; +import { emptyResponse } from '../../openapi/util/standard-responses'; export default class ArchiveController extends Controller { private readonly logger: Logger; diff --git a/src/lib/routes/admin-api/context.ts b/src/lib/routes/admin-api/context.ts index 3c1a169088..1dbf694f8a 100644 --- a/src/lib/routes/admin-api/context.ts +++ b/src/lib/routes/admin-api/context.ts @@ -26,8 +26,8 @@ import { UpsertContextFieldSchema } from '../../openapi/spec/upsert-context-fiel import { createRequestSchema, createResponseSchema } from '../../openapi'; import { serializeDates } from '../../types/serialize-dates'; import NotFoundError from '../../error/notfound-error'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { NameSchema } from '../../openapi/spec/name-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; interface ContextParam { contextField: string; diff --git a/src/lib/routes/admin-api/environments.ts b/src/lib/routes/admin-api/environments.ts index 2cd1404e60..66a8887b64 100644 --- a/src/lib/routes/admin-api/environments.ts +++ b/src/lib/routes/admin-api/environments.ts @@ -16,7 +16,7 @@ import { EnvironmentSchema, } from '../../openapi/spec/environment-schema'; import { SortOrderSchema } from '../../openapi/spec/sort-order-schema'; -import { emptyResponse } from '../../openapi/spec/empty-response'; +import { emptyResponse } from '../../openapi/util/standard-responses'; interface EnvironmentParam { name: string; diff --git a/src/lib/routes/admin-api/feature.ts b/src/lib/routes/admin-api/feature.ts index 320d2f75eb..6abbd97129 100644 --- a/src/lib/routes/admin-api/feature.ts +++ b/src/lib/routes/admin-api/feature.ts @@ -25,7 +25,7 @@ import { TagsSchema } from '../../openapi/spec/tags-schema'; import { serializeDates } from '../../types/serialize-dates'; import { OpenApiService } from '../../services/openapi-service'; import { createRequestSchema, createResponseSchema } from '../../openapi'; -import { emptyResponse } from '../../openapi/spec/empty-response'; +import { emptyResponse } from '../../openapi/util/standard-responses'; const version = 1; diff --git a/src/lib/routes/admin-api/metrics.ts b/src/lib/routes/admin-api/metrics.ts index 28b32497b9..cd9db42b04 100644 --- a/src/lib/routes/admin-api/metrics.ts +++ b/src/lib/routes/admin-api/metrics.ts @@ -5,10 +5,10 @@ import { IUnleashConfig } from '../../types/option'; import { IUnleashServices } from '../../types/services'; import { Logger } from '../../logger'; import ClientInstanceService from '../../services/client-metrics/instance-service'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { createRequestSchema, createResponseSchema } from '../../openapi'; import { ApplicationSchema } from '../../openapi/spec/application-schema'; import { ApplicationsSchema } from '../../openapi/spec/applications-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; class MetricsController extends Controller { private logger: Logger; diff --git a/src/lib/routes/admin-api/project/environments.ts b/src/lib/routes/admin-api/project/environments.ts index f54ef1a6d7..a135a7450a 100644 --- a/src/lib/routes/admin-api/project/environments.ts +++ b/src/lib/routes/admin-api/project/environments.ts @@ -7,7 +7,7 @@ import EnvironmentService from '../../../services/environment-service'; import { UPDATE_PROJECT } from '../../../types/permissions'; import { createRequestSchema } from '../../../openapi'; import { ProjectEnvironmentSchema } from '../../../openapi/spec/project-environment-schema'; -import { emptyResponse } from '../../../openapi/spec/empty-response'; +import { emptyResponse } from '../../../openapi/util/standard-responses'; const PREFIX = '/:projectId/environments'; diff --git a/src/lib/routes/admin-api/project/features.ts b/src/lib/routes/admin-api/project/features.ts index 20f15d803b..d4ad3b3f3b 100644 --- a/src/lib/routes/admin-api/project/features.ts +++ b/src/lib/routes/admin-api/project/features.ts @@ -35,7 +35,7 @@ import { serializeDates } from '../../../types/serialize-dates'; import { OpenApiService } from '../../../services/openapi-service'; import { createRequestSchema, createResponseSchema } from '../../../openapi'; import { FeatureEnvironmentSchema } from '../../../openapi/spec/feature-environment-schema'; -import { emptyResponse } from '../../../openapi/spec/empty-response'; +import { emptyResponse } from '../../../openapi/util/standard-responses'; interface FeatureStrategyParams { projectId: string; diff --git a/src/lib/routes/admin-api/state.ts b/src/lib/routes/admin-api/state.ts index 36b264f95a..6895678c18 100644 --- a/src/lib/routes/admin-api/state.ts +++ b/src/lib/routes/admin-api/state.ts @@ -13,8 +13,8 @@ import StateService from '../../services/state-service'; import { IAuthRequest } from '../unleash-types'; import { OpenApiService } from '../../services/openapi-service'; import { createRequestSchema, createResponseSchema } from '../../openapi'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { ExportParametersSchema } from '../../openapi/spec/export-parameters-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; const upload = multer({ limits: { fileSize: 5242880 } }); const paramToBool = (param, def) => { diff --git a/src/lib/routes/admin-api/strategy.ts b/src/lib/routes/admin-api/strategy.ts index 4f323f588e..2443b3e6de 100644 --- a/src/lib/routes/admin-api/strategy.ts +++ b/src/lib/routes/admin-api/strategy.ts @@ -13,7 +13,6 @@ import { import { Request, Response } from 'express'; import { IAuthRequest } from '../unleash-types'; import { OpenApiService } from '../../services/openapi-service'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { createRequestSchema, createResponseSchema } from '../../openapi'; import { strategySchema, @@ -24,6 +23,7 @@ import { StrategiesSchema, } from '../../openapi/spec/strategies-schema'; import { UpsertStrategySchema } from '../../openapi/spec/upsert-strategy-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; const version = 1; diff --git a/src/lib/routes/admin-api/tag-type.ts b/src/lib/routes/admin-api/tag-type.ts index 8b56dfca26..4b481f9470 100644 --- a/src/lib/routes/admin-api/tag-type.ts +++ b/src/lib/routes/admin-api/tag-type.ts @@ -14,7 +14,6 @@ import { Logger } from '../../logger'; import { IAuthRequest } from '../unleash-types'; import { createRequestSchema, createResponseSchema } from '../../openapi'; import { TagTypesSchema } from '../../openapi/spec/tag-types-schema'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { ValidateTagTypeSchema } from '../../openapi/spec/validate-tag-type-schema'; import { tagTypeSchema, @@ -22,6 +21,7 @@ import { } from '../../openapi/spec/tag-type-schema'; import { UpdateTagTypeSchema } from '../../openapi/spec/update-tag-type-schema'; import { OpenApiService } from '../../services/openapi-service'; +import { emptyResponse } from '../../openapi/util/standard-responses'; const version = 1; diff --git a/src/lib/routes/admin-api/tag.ts b/src/lib/routes/admin-api/tag.ts index b35b0f3e6b..86a40403e9 100644 --- a/src/lib/routes/admin-api/tag.ts +++ b/src/lib/routes/admin-api/tag.ts @@ -10,7 +10,6 @@ import { NONE, UPDATE_FEATURE } from '../../types/permissions'; import { extractUsername } from '../../util/extract-user'; import { IAuthRequest } from '../unleash-types'; import { createRequestSchema, createResponseSchema } from '../../openapi'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { tagsSchema, TagsSchema } from '../../openapi/spec/tags-schema'; import { TagSchema } from '../../openapi/spec/tag-schema'; import { OpenApiService } from '../../services/openapi-service'; @@ -18,6 +17,7 @@ import { tagWithVersionSchema, TagWithVersionSchema, } from '../../openapi/spec/tag-with-version-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; const version = 1; diff --git a/src/lib/routes/admin-api/user-admin.ts b/src/lib/routes/admin-api/user-admin.ts index 60af3b8381..ca9a556c0f 100644 --- a/src/lib/routes/admin-api/user-admin.ts +++ b/src/lib/routes/admin-api/user-admin.ts @@ -14,7 +14,6 @@ import { IUser, SimpleAuthSettings } from '../../server-impl'; import { simpleAuthKey } from '../../types/settings/simple-auth-settings'; import { anonymise } from '../../util/anonymise'; import { OpenApiService } from '../../services/openapi-service'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { createRequestSchema, createResponseSchema } from '../../openapi'; import { userSchema, UserSchema } from '../../openapi/spec/user-schema'; import { serializeDates } from '../../types/serialize-dates'; @@ -31,6 +30,7 @@ import { resetPasswordSchema, ResetPasswordSchema, } from '../../openapi/spec/reset-password-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; export default class UserAdminController extends Controller { private anonymise: boolean = false; diff --git a/src/lib/routes/admin-api/user.ts b/src/lib/routes/admin-api/user.ts index b1ceab2b84..c995611ace 100644 --- a/src/lib/routes/admin-api/user.ts +++ b/src/lib/routes/admin-api/user.ts @@ -10,11 +10,11 @@ import UserSplashService from '../../services/user-splash-service'; import { ADMIN, NONE } from '../../types/permissions'; import { OpenApiService } from '../../services/openapi-service'; import { createRequestSchema, createResponseSchema } from '../../openapi'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { meSchema, MeSchema } from '../../openapi/spec/me-schema'; import { serializeDates } from '../../types/serialize-dates'; import { IUserPermission } from '../../types/stores/access-store'; import { PasswordSchema } from '../../openapi/spec/password-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; class UserController extends Controller { private accessService: AccessService; diff --git a/src/lib/routes/auth/reset-password-controller.ts b/src/lib/routes/auth/reset-password-controller.ts index 206a9e8429..d870044ca8 100644 --- a/src/lib/routes/auth/reset-password-controller.ts +++ b/src/lib/routes/auth/reset-password-controller.ts @@ -6,13 +6,13 @@ import { IUnleashConfig } from '../../types/option'; import { IUnleashServices } from '../../types'; import { NONE } from '../../types/permissions'; import { createRequestSchema, createResponseSchema } from '../../openapi'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { OpenApiService } from '../../services/openapi-service'; import { tokenUserSchema, TokenUserSchema, } from '../../openapi/spec/token-user-schema'; import { EmailSchema } from '../../openapi/spec/email-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; interface IValidateQuery { token: string; diff --git a/src/lib/routes/client-api/metrics.ts b/src/lib/routes/client-api/metrics.ts index 4aacbeaea7..03b7333a74 100644 --- a/src/lib/routes/client-api/metrics.ts +++ b/src/lib/routes/client-api/metrics.ts @@ -11,8 +11,11 @@ import { User } from '../../server-impl'; import { IClientApp } from '../../types/model'; import { NONE } from '../../types/permissions'; import { OpenApiService } from '../../services/openapi-service'; -import { createRequestSchema, createResponseSchema } from '../../openapi'; -import { getStandardResponses } from '../../openapi/util/standard-responses'; +import { createRequestSchema } from '../../openapi'; +import { + emptyResponse, + getStandardResponses, +} from '../../openapi/util/standard-responses'; export default class ClientMetricsController extends Controller { logger: Logger; @@ -56,7 +59,7 @@ export default class ClientMetricsController extends Controller { requestBody: createRequestSchema('clientMetricsSchema'), responses: { ...getStandardResponses(400), - 202: createResponseSchema('emptyResponse'), + 202: emptyResponse, }, }), ], diff --git a/src/lib/routes/client-api/register.ts b/src/lib/routes/client-api/register.ts index 62bc57ae5f..79fb619675 100644 --- a/src/lib/routes/client-api/register.ts +++ b/src/lib/routes/client-api/register.ts @@ -10,9 +10,9 @@ import ApiUser from '../../types/api-user'; import { ALL } from '../../types/models/api-token'; import { NONE } from '../../types/permissions'; import { OpenApiService } from '../../services/openapi-service'; -import { emptyResponse } from '../../openapi/spec/empty-response'; import { createRequestSchema } from '../../openapi'; import { ClientApplicationSchema } from '../../openapi/spec/client-application-schema'; +import { emptyResponse } from '../../openapi/util/standard-responses'; export default class RegisterController extends Controller { logger: Logger; diff --git a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap index 0d6a577bf4..116a216944 100644 --- a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap +++ b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap @@ -5671,13 +5671,6 @@ If the provided project does not exist, the list of events will be empty.", }, "responses": Object { "202": Object { - "content": Object { - "application/json": Object { - "schema": Object { - "$ref": "#/components/schemas/emptyResponse", - }, - }, - }, "description": "emptyResponse", }, "400": Object {