Added getTags endpoint + doc
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
{
"name": "Users",
"description": "Users API"
+ },
+ {
+ "name": "Tags",
+ "description": "Tags API"
}
],
"paths": {
}
}
}
+ },
+ "/api/tags": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Retrieve a list of Tags",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/Issuer"
+ },
+ {
+ "$ref": "#/components/parameters/Search"
+ },
+ {
+ "$ref": "#/components/parameters/UserID"
+ },
+ {
+ "in": "query",
+ "name": "Active",
+ "description": "Active attribute",
+ "schema": {
+ "type": "boolean"
+ }
+ }
+ ],
+ "tags": [
+ "Tags"
+ ],
+ "responses": {
+ "200": {
+ "description": "Return tags list",
+ "content": {
+ "application/json": {
+ "example": {
+ "count": 1,
+ "result": [
+ {
+ "active": true,
+ "createdOn": "2021-03-05T15:03:08.684Z",
+ "default": false,
+ "description": "###########",
+ "issuer": true,
+ "ocpiToken": null,
+ "userID": "###",
+ "id": "###"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/500BackendError"
+ }
+ }
+ }
}
},
"components": {

MODIFY
src/server/rest/v1/router/GlobalRouter.ts
src/server/rest/v1/router/GlobalRouter.ts
@@ -5,6 +5,7 @@ import AuthService from '../service/AuthService';
import ChargingStationRouter from './api/ChargingStationRouter';
import { StatusCodes } from 'http-status-codes';
import SwaggerRouter from './doc/SwaggerRouter';
+import TagRouter from './api/TagRouter';
import TenantRouter from './api/TenantRouter';
import TransactionRouter from './api/TransactionRouter';
import UserRouter from './api/UserRouter';
@@ -32,10 +33,11 @@ export default class GlobalRouter {
protected buildRouteAPI(): void {
this.router.use('/api', AuthService.authenticate(), [
- new TenantRouter().buildRoutes(),
new ChargingStationRouter().buildRoutes(),
+ new TagRouter().buildRoutes(),
+ new TenantRouter().buildRoutes(),
new TransactionRouter().buildRoutes(),
- new UserRouter().buildRoutes()
+ new UserRouter().buildRoutes(),
]);
}

ADD
src/server/rest/v1/router/api/TagRouter.ts
+/* eslint-disable @typescript-eslint/no-misused-promises */
+import { ServerAction, ServerRoute } from '../../../../../types/Server';
+import express, { NextFunction, Request, Response } from 'express';
+
+import RouterUtils from '../RouterUtils';
+import TagService from '../../service/TagService';
+
+export default class TagRouter {
+ private router: express.Router;
+
+ public constructor() {
+ this.router = express.Router();
+ }
+
+ public buildRoutes(): express.Router {
+ this.buildRouteTags();
+ this.buildRouteTag();
+ return this.router;
+ }
+
+ protected buildRouteTags(): void {
+ this.router.get(`/${ServerRoute.REST_TAGS}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(TagService.handleGetTags.bind(this), ServerAction.TAGS, req, res, next);
+ });
+ }
+
+ protected buildRouteTag(): void {
+ this.router.get(`/${ServerRoute.REST_TAG}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(TagService.handleGetTag.bind(this), ServerAction.TAG, req, res, next);
+ });
+ }
+}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -441,6 +441,9 @@ export enum ServerRoute {
REST_USERS = 'users',
REST_USER = 'users/:id',
+ REST_TAGS = 'tags',
+ REST_TAG = 'tags/:id',
+
REST_PING = 'ping',
REST_TENANTS = 'tenants'

Added getTags endpoint + doc