Skip to content

Commit 2c0e0b7

Browse files
committed
fix: array spread issue
1 parent ccb4fad commit 2c0e0b7

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/schema-parser/base-schema-parsers/jsonld-context.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export class JsonLdContextSchemaParser extends MonoSchemaParser {
99
// Handle string context (URI reference)
1010
if (typeof contextSchema === "string") {
1111
return {
12-
...(typeof this.schema === "object" ? this.schema : {}),
12+
...(typeof this.schema === "object" && !Array.isArray(this.schema)
13+
? this.schema
14+
: {}),
1315
$schemaPath: this.schemaPath.slice(),
1416
$parsedSchema: true,
1517
schemaType: SCHEMA_TYPES.JSONLD_CONTEXT,
@@ -24,7 +26,9 @@ export class JsonLdContextSchemaParser extends MonoSchemaParser {
2426
// Handle array context
2527
if (Array.isArray(contextSchema)) {
2628
return {
27-
...(typeof this.schema === "object" ? this.schema : {}),
29+
...(typeof this.schema === "object" && !Array.isArray(this.schema)
30+
? this.schema
31+
: {}),
2832
$schemaPath: this.schemaPath.slice(),
2933
$parsedSchema: true,
3034
schemaType: SCHEMA_TYPES.JSONLD_CONTEXT,
@@ -49,7 +53,9 @@ export class JsonLdContextSchemaParser extends MonoSchemaParser {
4953
const contextProperties = this.getContextSchemaContent(contextSchema);
5054

5155
return {
52-
...(typeof this.schema === "object" ? this.schema : {}),
56+
...(typeof this.schema === "object" && !Array.isArray(this.schema)
57+
? this.schema
58+
: {}),
5359
$schemaPath: this.schemaPath.slice(),
5460
$parsedSchema: true,
5561
schemaType: SCHEMA_TYPES.JSONLD_CONTEXT,

src/schema-parser/base-schema-parsers/jsonld-entity.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export class JsonLdEntitySchemaParser extends MonoSchemaParser {
2020
entityName = entityName || "JsonLdEntity";
2121

2222
return {
23-
...(typeof this.schema === "object" ? this.schema : {}),
23+
...(typeof this.schema === "object" && !Array.isArray(this.schema)
24+
? this.schema
25+
: {}),
2426
$schemaPath: this.schemaPath.slice(),
2527
$parsedSchema: true,
2628
schemaType: SCHEMA_TYPES.JSONLD_ENTITY,

src/schema-parser/base-schema-parsers/jsonld-type.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export class JsonLdTypeSchemaParser extends MonoSchemaParser {
88
// Handle single type
99
if (typeof typeSchema === "string") {
1010
return {
11-
...(typeof this.schema === "object" ? this.schema : {}),
11+
...(typeof this.schema === "object" && !Array.isArray(this.schema)
12+
? this.schema
13+
: {}),
1214
$schemaPath: this.schemaPath.slice(),
1315
$parsedSchema: true,
1416
schemaType: SCHEMA_TYPES.JSONLD_TYPE,
@@ -27,7 +29,9 @@ export class JsonLdTypeSchemaParser extends MonoSchemaParser {
2729
);
2830

2931
return {
30-
...(typeof this.schema === "object" ? this.schema : {}),
32+
...(typeof this.schema === "object" && !Array.isArray(this.schema)
33+
? this.schema
34+
: {}),
3135
$schemaPath: this.schemaPath.slice(),
3236
$parsedSchema: true,
3337
schemaType: SCHEMA_TYPES.JSONLD_TYPE,
@@ -50,7 +54,9 @@ export class JsonLdTypeSchemaParser extends MonoSchemaParser {
5054
);
5155

5256
return {
53-
...(typeof this.schema === "object" ? this.schema : {}),
57+
...(typeof this.schema === "object" && !Array.isArray(this.schema)
58+
? this.schema
59+
: {}),
5460
$schemaPath: this.schemaPath.slice(),
5561
$parsedSchema: true,
5662
schemaType: SCHEMA_TYPES.JSONLD_TYPE,

0 commit comments

Comments
 (0)