fix: make schema more lenient while parsing public data structures
This commit is contained in:
@@ -10,7 +10,7 @@ export const FormDataKeyValue = z.object({
|
||||
z.union([
|
||||
z.object({
|
||||
isFile: z.literal(true),
|
||||
value: z.array(z.instanceof(Blob))
|
||||
value: z.array(z.instanceof(Blob).nullable())
|
||||
}),
|
||||
z.object({
|
||||
isFile: z.literal(false),
|
||||
@@ -31,11 +31,11 @@ export type HoppRESTReqBodyFormData = z.infer<typeof HoppRESTReqBodyFormData>
|
||||
export const HoppRESTReqBody = z.union([
|
||||
z.object({
|
||||
contentType: z.literal(null),
|
||||
body: z.literal(null)
|
||||
body: z.literal(null).catch(null)
|
||||
}),
|
||||
z.object({
|
||||
contentType: z.literal("multipart/form-data"),
|
||||
body: FormDataKeyValue
|
||||
body: z.array(FormDataKeyValue).catch([])
|
||||
}),
|
||||
z.object({
|
||||
contentType: z.union([
|
||||
@@ -48,7 +48,7 @@ export const HoppRESTReqBody = z.union([
|
||||
z.literal("text/html"),
|
||||
z.literal("text/plain"),
|
||||
]),
|
||||
body: z.string()
|
||||
body: z.string().catch("")
|
||||
})
|
||||
])
|
||||
|
||||
@@ -62,36 +62,36 @@ export type HoppRESTAuthNone = z.infer<typeof HoppRESTAuthNone>
|
||||
|
||||
export const HoppRESTAuthBasic = z.object({
|
||||
authType: z.literal("basic"),
|
||||
username: z.string(),
|
||||
password: z.string(),
|
||||
username: z.string().catch(""),
|
||||
password: z.string().catch(""),
|
||||
})
|
||||
|
||||
export type HoppRESTAuthBasic = z.infer<typeof HoppRESTAuthBasic>
|
||||
|
||||
export const HoppRESTAuthBearer = z.object({
|
||||
authType: z.literal("bearer"),
|
||||
token: z.string(),
|
||||
token: z.string().catch(""),
|
||||
})
|
||||
|
||||
export type HoppRESTAuthBearer = z.infer<typeof HoppRESTAuthBearer>
|
||||
|
||||
export const HoppRESTAuthOAuth2 = z.object({
|
||||
authType: z.literal("oauth-2"),
|
||||
token: z.string(),
|
||||
oidcDiscoveryURL: z.string(),
|
||||
authURL: z.string(),
|
||||
accessTokenURL: z.string(),
|
||||
clientID: z.string(),
|
||||
scope: z.string(),
|
||||
token: z.string().catch(""),
|
||||
oidcDiscoveryURL: z.string().catch(""),
|
||||
authURL: z.string().catch(""),
|
||||
accessTokenURL: z.string().catch(""),
|
||||
clientID: z.string().catch(""),
|
||||
scope: z.string().catch(""),
|
||||
})
|
||||
|
||||
export type HoppRESTAuthOAuth2 = z.infer<typeof HoppRESTAuthOAuth2>
|
||||
|
||||
export const HoppRESTAuthAPIKey = z.object({
|
||||
authType: z.literal("api-key"),
|
||||
key: z.string(),
|
||||
value: z.string(),
|
||||
addTo: z.string(),
|
||||
key: z.string().catch(""),
|
||||
value: z.string().catch(""),
|
||||
addTo: z.string().catch("Headers"),
|
||||
})
|
||||
|
||||
export type HoppRESTAuthAPIKey = z.infer<typeof HoppRESTAuthAPIKey>
|
||||
@@ -112,9 +112,9 @@ export type HoppRESTAuth = z.infer<typeof HoppRESTAuth>
|
||||
|
||||
export const HoppRESTParams = z.array(
|
||||
z.object({
|
||||
key: z.string(),
|
||||
value: z.string(),
|
||||
active: z.boolean()
|
||||
key: z.string().catch(""),
|
||||
value: z.string().catch(""),
|
||||
active: z.boolean().catch(true)
|
||||
})
|
||||
)
|
||||
|
||||
@@ -122,9 +122,9 @@ export type HoppRESTParams = z.infer<typeof HoppRESTParams>
|
||||
|
||||
export const HoppRESTHeaders = z.array(
|
||||
z.object({
|
||||
key: z.string(),
|
||||
value: z.string(),
|
||||
active: z.boolean()
|
||||
key: z.string().catch(""),
|
||||
value: z.string().catch(""),
|
||||
active: z.boolean().catch(true)
|
||||
})
|
||||
)
|
||||
|
||||
@@ -139,8 +139,8 @@ const V1_SCHEMA = z.object({
|
||||
endpoint: z.string(),
|
||||
params: HoppRESTParams,
|
||||
headers: HoppRESTHeaders,
|
||||
preRequestScript: z.string(),
|
||||
testScript: z.string(),
|
||||
preRequestScript: z.string().catch(""),
|
||||
testScript: z.string().catch(""),
|
||||
|
||||
auth: HoppRESTAuth,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user