diff --git a/src/core/Route.ts b/src/core/Route.ts index f7bd3214..eed4550c 100644 --- a/src/core/Route.ts +++ b/src/core/Route.ts @@ -51,9 +51,9 @@ export interface SCRoute { method: SCRouteHttpVerbs; /** - * List of obligatory parameters that have to be set via the requested path + * Map of obligatory parameters and their type that have to be set via the requested path */ - obligatoryParameters?: string[]; + obligatoryParameters?: { [k: string]: string }; /** * Name of the type of the request body @@ -84,7 +84,7 @@ export abstract class SCAbstractRoute implements SCRoute { 'SCErrorResponse', ]; method: SCRouteHttpVerbs = 'GET'; - obligatoryParameters?: string[]; + obligatoryParameters?: { [k: string]: string }; requestBodyName = 'any'; responseBodyName = 'any'; statusCodeSuccess = 200; @@ -97,8 +97,8 @@ export abstract class SCAbstractRoute implements SCRoute { let obligatoryParameters: string[] = []; - if (Array.isArray(this.obligatoryParameters)) { - obligatoryParameters = this.obligatoryParameters; + if (typeof this.obligatoryParameters === 'object') { + obligatoryParameters = Object.keys(this.obligatoryParameters); } if (Object.keys(parameters).length > obligatoryParameters.length) { diff --git a/src/core/protocol/routes/TYPE/UID/ThingUpdateRequest.ts b/src/core/protocol/routes/TYPE/UID/ThingUpdateRequest.ts index 99a50f7a..d3628540 100644 --- a/src/core/protocol/routes/TYPE/UID/ThingUpdateRequest.ts +++ b/src/core/protocol/routes/TYPE/UID/ThingUpdateRequest.ts @@ -34,10 +34,10 @@ export class SCThingUpdateRoute extends SCAbstractRoute { 'SCValidationErrorResponse', ]; this.method = 'PUT'; - this.obligatoryParameters = [ - 'TYPE', - 'UID', - ]; + this.obligatoryParameters = { + TYPE: 'SCThingTypes', + UID: 'SCUuid', + }; this.requestBodyName = 'SCThingUpdateRequest'; this.responseBodyName = 'SCThingUpdateResponse'; this.statusCodeSuccess = 200; diff --git a/src/core/protocol/routes/bulk/UID/BulkAddRequest.ts b/src/core/protocol/routes/bulk/UID/BulkAddRequest.ts index b2ae26b1..819ff29e 100644 --- a/src/core/protocol/routes/bulk/UID/BulkAddRequest.ts +++ b/src/core/protocol/routes/bulk/UID/BulkAddRequest.ts @@ -34,7 +34,9 @@ export class SCBulkAddRoute extends SCAbstractRoute { 'SCValidationErrorResponse', ]; this.method = 'POST'; - this.obligatoryParameters = ['UID']; + this.obligatoryParameters = { + UID: 'SCUuid', + }; this.requestBodyName = 'SCBulkAddRequest'; this.responseBodyName = 'SCBulkAddResponse'; this.statusCodeSuccess = 201; diff --git a/src/core/protocol/routes/bulk/UID/BulkDoneRequest.ts b/src/core/protocol/routes/bulk/UID/BulkDoneRequest.ts index ef011ece..ff585dfd 100644 --- a/src/core/protocol/routes/bulk/UID/BulkDoneRequest.ts +++ b/src/core/protocol/routes/bulk/UID/BulkDoneRequest.ts @@ -34,7 +34,9 @@ export class SCBulkDoneRoute extends SCAbstractRoute { 'SCValidationErrorResponse', ]; this.method = 'POST'; - this.obligatoryParameters = ['UID']; + this.obligatoryParameters = { + UID: 'SCUuid', + }; this.requestBodyName = 'SCBulkDoneRequest'; this.responseBodyName = 'SCBulkDoneResponse'; this.statusCodeSuccess = 204;