Added tag-get by id schema
ADD
src/assets/server/rest/v1/schemas/tag/tag-get.json
+{
+ "title": "Get a Tag",
+ "description": "",
+ "type": "object",
+ "properties": {
+ "ID": {
+ "$ref": "tag.json#/definitions/id"
+ },
+ "ProjectFields": {
+ "$ref": "common.json#/definitions/projectFields"
+ }
+ },
+ "required": [
+ "ID"
+ ]
+}

MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -46,7 +46,7 @@ export default class TagService {
public static async handleGetTag(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter request
- const filteredRequest = TagSecurity.filterTagRequestByID(req.query);
+ const filteredRequest = TagValidator.getInstance().validateTagGetByID(req.query);
// Check and Get Tag
const tag = await UtilsService.checkAndGetTagAuthorization(req.tenant, req.user, filteredRequest.ID, Action.READ, action,
{ withUser: true }, true);
@@ -63,7 +63,7 @@ export default class TagService {
public static async handleDeleteTags(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const tagsIDs = TagValidator.getInstance().validateTagsDeleteMany(req.body).tagIDs;
+ const tagsIDs = TagValidator.getInstance().validateTagsDelete(req.body).tagIDs;
// Delete
const result = await TagService.deleteTags(req.tenant, action, req.user, tagsIDs);
// Return

MODIFY
src/server/rest/v1/validator/TagValidator.ts
src/server/rest/v1/validator/TagValidator.ts
+import { HttpTagRequest, HttpTagsRequest } from '../../../../types/requests/HttpTagRequest';
import Tag, { ImportedTag } from '../../../../types/Tag';
-import { HttpTagsRequest } from '../../../../types/requests/HttpTagRequest';
import Schema from '../../../../types/validator/Schema';
import SchemaValidator from './SchemaValidator';
import fs from 'fs';
@@ -12,7 +12,8 @@ export default class TagValidator extends SchemaValidator {
private tagCreate: Schema;
private tagUpdate: Schema;
private tagsGet: Schema;
- private tagsDeleteMany: Schema;
+ private tagGet: Schema;
+ private tagsDelete: Schema;
private constructor() {
super('TagValidator');
@@ -20,7 +21,8 @@ export default class TagValidator extends SchemaValidator {
this.tagCreate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tag-create.json`, 'utf8'));
this.tagUpdate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tag-update.json`, 'utf8'));
this.tagsGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tags-get.json`, 'utf8'));
- this.tagsDeleteMany = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tags-delete.json`, 'utf8'));
+ this.tagGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tag-get.json`, 'utf8'));
+ this.tagsDelete = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tags-delete.json`, 'utf8'));
}
public static getInstance(): TagValidator {
@@ -49,8 +51,13 @@ export default class TagValidator extends SchemaValidator {
return data;
}
- validateTagsDeleteMany(data: { tagIDs: string[] }): { tagIDs: string[] } {
- this.validate(this.tagsDeleteMany, data);
+ validateTagGetByID(data: any): HttpTagRequest {
+ this.validate(this.tagGet, data);
+ return data;
+ }
+
+ validateTagsDelete(data: { tagIDs: string[] }): { tagIDs: string[] } {
+ this.validate(this.tagsDelete, data);
return data;
}
}

Added tag-get by id schema