Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: add fallback for `type` field in `restTabState` schema (#4398)

Nivedin853500402325
diff --git a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts
index a6e3887d5..9afdbac7d 100644
--- a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts
+++ b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts
@@ -533,7 +533,7 @@ export const REST_TAB_STATE_SCHEMA = z
z.object({
// !Versioned entity
request: entityReference(HoppRESTRequest),
- type: z.literal("request"),
+ type: z.literal("request").catch("request"),
isDirty: z.boolean(),
saveContext: z.optional(HoppRESTSaveContextSchema),
response: z.optional(z.nullable(HoppRESTResponseSchema)),
@@ -544,7 +544,7 @@ export const REST_TAB_STATE_SCHEMA = z
cancelFunction: z.optional(z.function()),
}),
z.object({
- type: z.literal("example-response"),
+ type: z.literal("example-response").catch("example-response"),
response: HoppRESTRequestResponse,
saveContext: z.optional(HoppRESTSaveContextSchema),
isDirty: z.boolean(),