1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

refactor: fix empty response usage (#1783)

* refactor: fix empty response usage

* refactor: move emptyResponse into standard-responses.ts
This commit is contained in:
olav 2022-06-30 14:48:39 +02:00 committed by GitHub
parent 2729999bed
commit 98c7b915c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 27 additions and 30 deletions

View File

@ -1,3 +0,0 @@
export const emptyResponse = {
description: 'emptyResponse',
};

View File

@ -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`.',

View File

@ -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<IUnleashServices, 'addonService' | 'openApiService'>;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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';

View File

@ -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;

View File

@ -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) => {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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,
},
}),
],

View File

@ -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;

View File

@ -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 {