Skip to content

Commit

Permalink
add rest endpoints for creating/deleting images in processes
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasMGo committed Nov 27, 2023
1 parent 7ae1501 commit 166fc87
Show file tree
Hide file tree
Showing 6 changed files with 386 additions and 56 deletions.
109 changes: 92 additions & 17 deletions src/management-system-v2/lib/openapiSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,21 @@ export interface paths {
get: operations['getVersionById'];
};
'/process/{definitionId}/images': {
/** @description Get all images used in a process. */
get: operations['getImageOfProcessById'];
/** @description Get all image filenames used in a process. */
get: operations['getImageFilenamesByProcessId'];
/** @description Post a new image for a process. */
post: operations['postImageByProcessId'];
};
'/process/{definitionId}/images/{imageFileName}': {
/** @description Get a specific image og a process. */
get: operations['getImagesByProcessId'];
/** @description Get a specific image of a process. */
get: operations['getImageByFilename'];
/**
* @description Update a specific image of a process.
* If imageFileName exists, then it is updated with the body of the request (200 response), if not, then the image is created (201 response).
*/
put: operations['updateImageByFilename'];
/** @description Delete a specific image of a process. */
delete: operations['deleteImageByFilename'];
};
'/process/{definitionId}/user-tasks': {
/** @description Get all user tasks used in a process. */
Expand Down Expand Up @@ -771,8 +780,8 @@ export interface operations {
403: components['responses']['403_validationFailed'];
};
};
/** @description Get all images used in a process. */
getImageOfProcessById: {
/** @description Get all image filenames used in a process. */
getImageFilenamesByProcessId: {
parameters: {
path: {
definitionId: components['parameters']['definitionId'];
Expand All @@ -782,36 +791,53 @@ export interface operations {
/** @description OK */
200: {
content: {
'image/png image/svg+xml image/jpeg': string;
'application/json': string[];
};
};
401: components['responses']['401_unauthenticated'];
403: components['responses']['403_validationFailed'];
};
};
/** @description Get a specific image og a process. */
getImagesByProcessId: {
/** @description Post a new image for a process. */
postImageByProcessId: {
parameters: {
path: {
definitionId: components['parameters']['definitionId'];
/** @description Filename of the image */
imageFileName: string;
};
};
requestBody?: {
/** @description Image file to be stored */
requestBody: {
content: {
'application/json': {
[key: string]: components['schemas']['image'];
'image/png image/svg+xml image/jpeg': unknown;
};
};
responses: {
/** @description Image created in the server */
201: {
content: {
'application/json': {
imageFileName?: string;
};
};
};
401: components['responses']['401_unauthenticated'];
403: components['responses']['403_validationFailed'];
};
};
/** @description Get a specific image of a process. */
getImageByFilename: {
parameters: {
path: {
definitionId: components['parameters']['definitionId'];
/** @description Filename of the image */
imageFileName: string;
};
};
responses: {
/** @description OK */
200: {
content: {
'application/json': {
''?: string;
};
'image/png image/svg+xml image/jpeg': string;
};
};
401: components['responses']['401_unauthenticated'];
Expand All @@ -822,6 +848,55 @@ export interface operations {
};
};
};
/**
* @description Update a specific image of a process.
* If imageFileName exists, then it is updated with the body of the request (200 response), if not, then the image is created (201 response).
*/
updateImageByFilename: {
parameters: {
path: {
definitionId: components['parameters']['definitionId'];
/** @description Filename of the image */
imageFileName: string;
};
};
/** @description Image file to be stored */
requestBody: {
content: {
'image/png image/svg+xml image/jpeg': unknown;
};
};
responses: {
/** @description Image updated */
200: {
content: never;
};
/** @description Image created in the server */
201: {
content: never;
};
401: components['responses']['401_unauthenticated'];
403: components['responses']['403_validationFailed'];
};
};
/** @description Delete a specific image of a process. */
deleteImageByFilename: {
parameters: {
path: {
definitionId: components['parameters']['definitionId'];
/** @description Filename of the image */
ImageFileName: string;
};
};
responses: {
/** @description The request returns 200 wether the image exists or not */
200: {
content: never;
};
401: components['responses']['401_unauthenticated'];
403: components['responses']['403_validationFailed'];
};
};
/** @description Get all user tasks used in a process. */
getUserTasksByProcessId: {
parameters: {
Expand Down
165 changes: 135 additions & 30 deletions src/management-system/src/backend/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
},
"/process/{definitionId}/images": {
"get": {
"operationId": "getImageOfProcessById",
"operationId": "getImageFilenamesByProcessId",
"tags": ["Process"],
"parameters": [
{
Expand All @@ -484,10 +484,13 @@
"200": {
"description": "OK",
"content": {
"image/png image/svg+xml image/jpeg": {
"application/json": {
"schema": {
"type": "string",
"description": "Requested image\n"
"type": "array",
"minItems": 0,
"items": {
"type": "string"
}
}
}
}
Expand All @@ -499,13 +502,53 @@
"$ref": "#/components/responses/403_validationFailed"
}
},
"description": "Get all images used in a process."
"description": "Get all image filenames used in a process."
},
"post": {
"operationId": "postImageByProcessId",
"tags": ["Process"],
"parameters": [
{
"$ref": "#/components/parameters/definitionId"
}
],
"requestBody": {
"required": true,
"content": {
"image/png image/svg+xml image/jpeg": {}
},
"description": "Image file to be stored"
},
"responses": {
"201": {
"description": "Image created in the server",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"imageFileName": {
"type": "string"
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/401_unauthenticated"
},
"403": {
"$ref": "#/components/responses/403_validationFailed"
}
},
"description": "Post a new image for a process."
}
},
"/process/{definitionId}/images/{imageFileName}": {
"get": {
"description": "Get a specific image og a process.",
"operationId": "getImagesByProcessId",
"description": "Get a specific image of a process.",
"operationId": "getImageByFilename",
"tags": ["Process"],
"parameters": [
{
Expand All @@ -521,30 +564,14 @@
"description": "Filename of the image"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/image"
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"image/png image/svg+xml image/jpeg": {
"schema": {
"type": "object",
"properties": {
"": {
"type": "string"
}
}
"type": "string",
"description": "Requested image\n"
}
}
}
Expand All @@ -559,6 +586,76 @@
"description": "Not Found"
}
}
},
"put": {
"description": "Update a specific image of a process.\nIf imageFileName exists, then it is updated with the body of the request (200 response), if not, then the image is created (201 response).",
"operationId": "updateImageByFilename",
"tags": ["Process"],
"parameters": [
{
"$ref": "#/components/parameters/definitionId"
},
{
"schema": {
"type": "string"
},
"name": "imageFileName",
"in": "path",
"required": true,
"description": "Filename of the image"
}
],
"requestBody": {
"required": true,
"content": {
"image/png image/svg+xml image/jpeg": {}
},
"description": "Image file to be stored"
},
"responses": {
"200": {
"description": "Image updated"
},
"201": {
"description": "Image created in the server"
},
"401": {
"$ref": "#/components/responses/401_unauthenticated"
},
"403": {
"$ref": "#/components/responses/403_validationFailed"
}
}
},
"delete": {
"operationId": "deleteImageByFilename",
"tags": ["Process"],
"parameters": [
{
"$ref": "#/components/parameters/definitionId"
},
{
"schema": {
"type": "string"
},
"name": "ImageFileName",
"in": "path",
"required": true,
"description": "Filename of the image"
}
],
"responses": {
"200": {
"description": "The request returns 200 wether the image exists or not"
},
"401": {
"$ref": "#/components/responses/401_unauthenticated"
},
"403": {
"$ref": "#/components/responses/403_validationFailed"
}
},
"description": "Delete a specific image of a process."
}
},
"/process/{definitionId}/user-tasks": {
Expand Down Expand Up @@ -1412,10 +1509,18 @@
{
"type": "object",
"properties": {
"username": { "type": "string" },
"firstName": { "type": "string" },
"lastName": { "type": "string" },
"email": { "type": "string" }
"username": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "string"
}
},
"required": ["username", "firstName", "lastName", "email"]
}
Expand Down
5 changes: 4 additions & 1 deletion src/management-system/src/backend/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ async function init() {
}

backendServer.use(express.text({ type: ['text/plain', 'text/html'] }));
backendServer.use(express.json());
backendServer.use(express.json({ limit: '1mb' }));
backendServer.use(
express.raw({ type: ['image/jpeg', 'image/png', 'image/svg+xml'], limit: '5mb' }),
);

if (config.useAuthorization) {
if (config.useAuth0) {
Expand Down
Loading

0 comments on commit 166fc87

Please sign in to comment.