mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 16:27:46 +00:00
Fix error schema validation issue
This commit is contained in:
@@ -6,9 +6,16 @@ import { DefaultResponseErrorsSchema } from "../routes/sanitizedSchemas";
|
|||||||
const isScimRoutes = (pathname: string) =>
|
const isScimRoutes = (pathname: string) =>
|
||||||
pathname.startsWith("/api/v1/scim/Users") || pathname.startsWith("/api/v1/scim/Groups");
|
pathname.startsWith("/api/v1/scim/Users") || pathname.startsWith("/api/v1/scim/Groups");
|
||||||
|
|
||||||
|
const isAcmeRoutes = (pathname: string) => pathname.startsWith("/api/v1/pki/acme/");
|
||||||
|
|
||||||
export const addErrorsToResponseSchemas = fp(async (server) => {
|
export const addErrorsToResponseSchemas = fp(async (server) => {
|
||||||
server.addHook("onRoute", (routeOptions) => {
|
server.addHook("onRoute", (routeOptions) => {
|
||||||
if (routeOptions.schema && routeOptions.schema.response && !isScimRoutes(routeOptions.path)) {
|
if (
|
||||||
|
routeOptions.schema &&
|
||||||
|
routeOptions.schema.response &&
|
||||||
|
!isScimRoutes(routeOptions.path) &&
|
||||||
|
!isAcmeRoutes(routeOptions.path)
|
||||||
|
) {
|
||||||
routeOptions.schema.response = {
|
routeOptions.schema.response = {
|
||||||
...DefaultResponseErrorsSchema,
|
...DefaultResponseErrorsSchema,
|
||||||
...routeOptions.schema.response
|
...routeOptions.schema.response
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ export const fastifyErrHandler = fastifyPlugin(async (server: FastifyZodProvider
|
|||||||
.send({
|
.send({
|
||||||
reqId: req.id,
|
reqId: req.id,
|
||||||
error: error.name,
|
error: error.name,
|
||||||
statusCode: error.status,
|
status: error.status,
|
||||||
type: `urn:ietf:params:acme:error:${error.type}`,
|
type: `urn:ietf:params:acme:error:${error.type}`,
|
||||||
detail: error.detail,
|
detail: error.detail,
|
||||||
message: error.message
|
message: error.message
|
||||||
|
|||||||
Reference in New Issue
Block a user