Skip to content
Open
Changes from 2 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
9 changes: 9 additions & 0 deletions src/schema-components-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@ export class SchemaComponentsMap {
}

createRef = (paths: string[]) => {
if (!Array.isArray(paths)) {
throw new Error(`Expected an array, but received: ${typeof paths}`);
}
if (paths.length === 0) {
throw new Error("Paths array cannot be empty.");
}
return ["#", ...paths].join("/");
};

parseRef = (ref: string) => {
if (!ref.startsWith("#/")) {
throw new Error(`Invalid ref format: ${ref}. It should start with "#/"`);
}
return ref.split("/");
};

Expand Down