Skip to content

Commit

Permalink
(chore) update spec diff alert
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilShahi committed Sep 9, 2022
1 parent 777fa33 commit 0149d03
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions backend/src/services/spec/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ export const generateAlertMessageFromReqErrors = (
let errorMessage = `${defaultErrorMessage} in request${
error["location"] ? ` ${error["location"]}` : ""
}.`
let path = pathArray.length > 0 ? pathArray.join("/") : ""
let path = pathArray.length > 0 ? pathArray.join(".") : ""
switch (error.keyword) {
case "required":
if (error.params?.missingProperty) {
path = path
? `${path}/${error.params.missingProperty}`
? `${path}.${error.params.missingProperty}`
: error.params.missingProperty
}
errorMessage = `Required property '${path}' is missing from request ${error["location"]}.`
Expand All @@ -142,7 +142,7 @@ export const generateAlertMessageFromReqErrors = (
case "additionalProperties":
if (error.params?.additionalProperty) {
path = path
? `${path}/${error.params.additionalProperty}`
? `${path}.${error.params.additionalProperty}`
: error.params.additionalProperty
}
errorMessage =
Expand All @@ -152,7 +152,7 @@ export const generateAlertMessageFromReqErrors = (
case "unevaluatedProperties":
if (error.params?.unevaluatedProperty) {
path = path
? `${path}/${error.params.unevaluatedProperty}`
? `${path}.${error.params.unevaluatedProperty}`
: error.params.unevaluatedProperty
}
errorMessage =
Expand All @@ -172,7 +172,7 @@ export const generateAlertMessageFromReqErrors = (
if (!error["location"]) {
errorMessage = `${defaultErrorMessage} in request.`
}
const errorField = path?.split("/")[0]
const errorField = path?.split(".")[0]
const tempPath = getPathToRequestLocation(
parameters,
error["location"] as Location,
Expand All @@ -196,12 +196,12 @@ export const generateAlertMessageFromRespErrors = (
const defaultErrorMessage =
error.message[0].toUpperCase() + error.message.slice(1)
let errorMessage = `${defaultErrorMessage} in response body.`
let path = pathArray.length > 0 ? pathArray.join("/") : ""
let path = pathArray.length > 0 ? pathArray.join(".") : ""
switch (error.keyword) {
case "required":
if (error.params?.missingProperty) {
path = path
? `${path}/${error.params.missingProperty}`
? `${path}.${error.params.missingProperty}`
: error.params.missingProperty
}
errorMessage = `Required property '${path}' is missing from response body.`
Expand All @@ -212,7 +212,7 @@ export const generateAlertMessageFromRespErrors = (
case "additionalProperties":
if (error.params?.additionalProperty) {
path = path
? `${path}/${error.params.additionalProperty}`
? `${path}.${error.params.additionalProperty}`
: error.params.additionalProperty
}
errorMessage =
Expand All @@ -222,7 +222,7 @@ export const generateAlertMessageFromRespErrors = (
case "unevaluatedProperties":
if (error.params?.unevaluatedProperty) {
path = path
? `${path}/${error.params.unevaluatedProperty}`
? `${path}.${error.params.unevaluatedProperty}`
: error.params.unevaluatedProperty
}
errorMessage =
Expand Down

0 comments on commit 0149d03

Please sign in to comment.