Skip to content

Commit

Permalink
Merge pull request #84 from kamorel/SHOWCASE-2282
Browse files Browse the repository at this point in the history
Add template hash to error response
  • Loading branch information
TimCsaky authored Feb 8, 2022
2 parents af223ea + 45ce058 commit 26fdd65
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion app/src/docs/v2.api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,38 @@ paths:
"400":
$ref: "#/components/responses/BadRequest"
"405":
$ref: "#/components/responses/MethodNotAllowed"
description: Template already cached
content:
application/json:
schema:
type: object
required:
- type
- title
- status
- detail
- hash
properties:
type:
type: string
description: "What type of problem, link to explanation of problem"
example: https://httpstatuses.com/405
title:
type: string
description: "Title of problem, generally the Http Status Code"
example: Method Not Allowed
status:
type: string
description: The Http Status code
example: 405
detail:
type: string
description: Short description of why this problem was raised.
example: File already cached. Hash '742d642a4704eb1babd8122ce0f03f209354279ae8292bb3961d13e21578b855'.
hash:
type: string
description: UUID for template cached on server.
example: 742d642a4704eb1babd8122ce0f03f209354279ae8292bb3961d13e21578b855
"422":
$ref: "#/components/responses/UnprocessableEntity"
default:
Expand Down
2 changes: 1 addition & 1 deletion app/src/routes/v2/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ templateRouter.post('/', upload, async (req, res) => {
// TODO: If `carbone.uploadCount` is greater than 1, check `req.files` array
const result = await fileCache.move(req.file.path, req.file.originalname);
if (!result.success) {
return new Problem(result.errorType, { detail: result.errorMsg }).send(res);
return new Problem(result.errorType, { detail: result.errorMsg, hash: result.hash }).send(res);
} else {
res.setHeader('X-Template-Hash', result.hash);
return res.send(result.hash);
Expand Down

0 comments on commit 26fdd65

Please sign in to comment.