Skip to content

Commit

Permalink
feat: add meta schema
Browse files Browse the repository at this point in the history
Also:
- Make object's `properties` optional
  • Loading branch information
brettz9 committed Jun 23, 2024
1 parent d3becc9 commit 582c268
Show file tree
Hide file tree
Showing 5 changed files with 957 additions and 193 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/schema.zodex
6 changes: 4 additions & 2 deletions src/dezerialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ const dezerializers = {
object: ((shape: SzObject, opts: DezerializerOptions) => {
let i = z.object(
Object.fromEntries(
Object.entries(shape.properties).map(([key, value]) => {
Object.entries(shape.properties ?? {}).map(([key, value]) => {
return [
key,
checkRef(value, opts) ||
Expand Down Expand Up @@ -595,7 +595,9 @@ export function dezerialize(
);

// Ensure we act on the same options as the main document JSON
return dezerialize(obj, options);
const dez = dezerialize(obj, options);
options.pathToSchema.set($ref, dez);
return dez;
};
}

Expand Down
Loading

0 comments on commit 582c268

Please sign in to comment.