From 6daddb3a87452b3ae2dd249f297154c1712f8d8d Mon Sep 17 00:00:00 2001 From: Sindre Gulseth Date: Fri, 15 Mar 2024 14:54:43 +0100 Subject: [PATCH] fix: schema extraction object type name --- .../schema/src/sanity/extractSchema.ts | 2 +- .../__snapshots__/extractSchema.test.ts.snap | 35 ------------------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/packages/@sanity/schema/src/sanity/extractSchema.ts b/packages/@sanity/schema/src/sanity/extractSchema.ts index 1b7681c734d..afc60f7f595 100644 --- a/packages/@sanity/schema/src/sanity/extractSchema.ts +++ b/packages/@sanity/schema/src/sanity/extractSchema.ts @@ -219,7 +219,7 @@ export function extractSchema( return {type: 'unknown'} satisfies UnknownTypeNode } - if (schemaType.type?.name !== 'document') { + if (schemaType.type?.name !== 'document' && schemaType.name !== 'object') { attributes._type = { type: 'objectAttribute', value: { diff --git a/packages/@sanity/schema/test/extractSchema/__snapshots__/extractSchema.test.ts.snap b/packages/@sanity/schema/test/extractSchema/__snapshots__/extractSchema.test.ts.snap index 4926d91ea69..7d5b125eeaa 100644 --- a/packages/@sanity/schema/test/extractSchema/__snapshots__/extractSchema.test.ts.snap +++ b/packages/@sanity/schema/test/extractSchema/__snapshots__/extractSchema.test.ts.snap @@ -1334,13 +1334,6 @@ Array [ "type": "objectAttribute", "value": Object { "attributes": Object { - "_type": Object { - "type": "objectAttribute", - "value": Object { - "type": "string", - "value": "object", - }, - }, "blocks": Object { "optional": true, "type": "objectAttribute", @@ -1797,13 +1790,6 @@ Array [ "value": Object { "of": Object { "attributes": Object { - "_type": Object { - "type": "objectAttribute", - "value": Object { - "type": "string", - "value": "object", - }, - }, "author": Object { "optional": true, "type": "objectAttribute", @@ -1953,13 +1939,6 @@ Array [ "value": Object { "of": Object { "attributes": Object { - "_type": Object { - "type": "objectAttribute", - "value": Object { - "type": "string", - "value": "object", - }, - }, "aNumber": Object { "optional": true, "type": "objectAttribute", @@ -2555,13 +2534,6 @@ Array [ "value": Object { "of": Object { "attributes": Object { - "_type": Object { - "type": "objectAttribute", - "value": Object { - "type": "string", - "value": "object", - }, - }, "aNumber": Object { "optional": true, "type": "objectAttribute", @@ -2618,13 +2590,6 @@ Array [ "type": "objectAttribute", "value": Object { "attributes": Object { - "_type": Object { - "type": "objectAttribute", - "value": Object { - "type": "string", - "value": "object", - }, - }, "blocks": Object { "optional": true, "type": "objectAttribute",