Added tags-get schema
ADD
src/assets/server/rest/v1/schemas/tag/tag-update.json
+{
+ "title": "Update a Tag",
+ "description": "",
+ "type": "object",
+ "properties": {
+ "id": {
+ "$ref": "tag.json#/definitions/id"
+ },
+ "visualID": {
+ "$ref": "tag.json#/definitions/visualID"
+ },
+ "description": {
+ "$ref": "tag.json#/definitions/description"
+ },
+ "active": {
+ "$ref": "tag.json#/definitions/active"
+ },
+ "issuer": {
+ "$ref": "tag.json#/definitions/issuer"
+ },
+ "default": {
+ "$ref": "tag.json#/definitions/default"
+ },
+ "userID": {
+ "$ref": "tag.json#/definitions/userID"
+ }
+ },
+ "required": [
+ "id",
+ "visualID",
+ "userID"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/tag/tags-get.json
+{
+ "title": "Get Tags",
+ "description": "",
+ "type": "object",
+ "properties": {
+ "Active": {
+ "$ref": "tag.json#/definitions/active"
+ },
+ "Issuer": {
+ "$ref": "tag.json#/definitions/issuer"
+ },
+ "UserID": {
+ "$ref": "user.json#/definitions/ids"
+ },
+ "Search": {
+ "$ref": "common.json#/definitions/search"
+ },
+ "SortFields": {
+ "$ref": "common.json#/definitions/sortFields"
+ },
+ "Skip": {
+ "$ref": "common.json#/definitions/skip"
+ },
+ "OnlyRecordCount": {
+ "$ref": "common.json#/definitions/onlyRecordCount"
+ },
+ "ProjectFields": {
+ "$ref": "common.json#/definitions/projectFields"
+ }
+ },
+ "required": []
+}

MODIFY
src/assets/server/rest/v1/schemas/user/user.json
src/assets/server/rest/v1/schemas/user/user.json
"id": {
"$ref": "common.json#/definitions/id"
},
+ "ids": {
+ "$ref": "common.json#/definitions/ids"
+ },
"name": {
"type": "string",
"minLength": 1,

MODIFY
src/assets/server/rest/v1/schemas/user/users-get.json
src/assets/server/rest/v1/schemas/user/users-get.json
"$ref": "common.json#/definitions/ids"
},
"UserID": {
- "$ref": "common.json#/definitions/ids"
+ "$ref": "user.json#/definitions/ids"
},
"Roles": {
"type": "string",
"$ref": "tag.json#/definitions/ids"
},
"ExcludeUserIDs": {
- "$ref": "common.json#/definitions/ids"
+ "$ref": "user.json#/definitions/ids"
},
"IncludeCarUserIDs": {
"$ref": "common.json#/definitions/ids"

MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -228,7 +228,7 @@ export default class TagService {
public static async handleUpdateTag(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = TagSecurity.filterTagUpdateRequest({ ...req.params, ...req.body }, req.user);
+ const filteredRequest = TagValidator.getInstance().validateTagUpdate({ ...req.params, ...req.body });
// Check
UtilsService.checkIfUserTagIsValid(filteredRequest, req);
// Check and Get Tag
@@ -726,7 +726,7 @@ export default class TagService {
private static async getTags(req: Request): Promise<DataResult<Tag>> {
// Filter
- const filteredRequest = TagSecurity.filterTagsRequest(req.query);
+ const filteredRequest = TagValidator.getInstance().validateTagsGet(req.query);
// Get authorization filters
const authorizationTagsFilters = await AuthorizationService.checkAndGetTagsAuthorizationFilters(
req.tenant, req.user, filteredRequest);

MODIFY
src/server/rest/v1/validator/TagValidator.ts
src/server/rest/v1/validator/TagValidator.ts
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';
@@ -9,11 +10,15 @@ export default class TagValidator extends SchemaValidator {
private static instance: TagValidator|null = null;
private importedTagCreation: Schema;
private tagCreate: Schema;
+ private tagUpdate: Schema;
+ private tagsGet: Schema;
private constructor() {
super('TagValidator');
this.importedTagCreation = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/imported-tag-create-req.json`, 'utf8'));
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'));
}
public static getInstance(): TagValidator {
@@ -31,4 +36,14 @@ export default class TagValidator extends SchemaValidator {
this.validate(this.tagCreate, tag);
return tag;
}
+
+ validateTagUpdate(tag: Tag): Tag {
+ this.validate(this.tagUpdate, tag);
+ return tag;
+ }
+
+ validateTagsGet(data: any): HttpTagsRequest {
+ this.validate(this.tagsGet, data);
+ return data;
+ }
}

Added tags-get schema