Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/structured-playground-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@open-rpc/playground": patch
---
Use structuredClone for deep copies.
6 changes: 3 additions & 3 deletions packages/playground/src/schema/tempLocalJsonSchemaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import localJsonSchema from './localJsonSchema.json';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function convertToLocalJsonSchema(schema: any): any {
if (!schema) return schema;
const schemaCopy = JSON.parse(JSON.stringify(schema));
const schemaCopy = structuredClone(schema);

if (!schemaCopy.definitions) {
schemaCopy.definitions = {};
Expand All @@ -13,13 +13,13 @@ export function convertToLocalJsonSchema(schema: any): any {
const resolvedDefinitions: Record<string, any> = {};

Object.entries(schemaCopy.definitions).forEach(([key, def]) => {
resolvedDefinitions[key] = JSON.parse(JSON.stringify(def));
resolvedDefinitions[key] = structuredClone(def);
});

// Process each definition from localJsonSchema
Object.entries(localJsonSchema.definitions).forEach(([key, def]) => {
// Deep clone the definition
resolvedDefinitions[key] = JSON.parse(JSON.stringify(def));
resolvedDefinitions[key] = structuredClone(def);
});

// Function to recursively replace "#" refs with inline schema
Expand Down