Skip to content

Commit 1daff10

Browse files
committed
Add OpenAPI dialect support and expose registration functions
1 parent fef4665 commit 1daff10

File tree

6 files changed

+14
-3
lines changed

6 files changed

+14
-3
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ All files | 81.81 | 66.66 | 80 | 88.88 |
2626

2727
## Limitations
2828

29-
The following are know limitations I'm hopeful can be addressed.
29+
The following are known limitations I'm hopeful can be addressed.
3030

3131
- Coverage can only be reported for `**/*.schema.json` and `**/schema.json`
3232
files.
3333
- Coverage can't be reported for embedded schemas.
3434
- Schemas in YAML aren't supported.
35-
- Custom vocabularies aren't supported.
36-
- There's no way to load schemas.
3735

3836
## Vitest
3937

src/vitest/coverage-provider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import "@hyperjump/json-schema/draft-2019-09";
1515
import "@hyperjump/json-schema/draft-07";
1616
import "@hyperjump/json-schema/draft-06";
1717
import "@hyperjump/json-schema/draft-04";
18+
import "@hyperjump/json-schema/openapi-3-0";
19+
import "@hyperjump/json-schema/openapi-3-1";
1820
import { compile, getSchema } from "@hyperjump/json-schema/experimental";
1921
import { astToCoverageMap } from "../coverage-util.js";
2022
import { fromJson } from "../json-util.js";

src/vitest/json-schema-matcher.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ import type { SchemaObject } from "@hyperjump/json-schema";
33
// eslint-disable-next-line @typescript-eslint/no-explicit-any
44
export const matchJsonSchema: (instance: any, uriOrSchema: string | SchemaObject | boolean) => AsyncExpectationResult;
55
export const toMatchJsonSchema: typeof matchJsonSchema;
6+
7+
export type { registerSchema, unregisterSchema } from "@hyperjump/json-schema/draft-2020-12";
8+
export type { loadDialect, defineVocabulary, addKeyword } from "@hyperjump/json-schema/experimental";

src/vitest/json-schema-matcher.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import "@hyperjump/json-schema/draft-2019-09";
66
import "@hyperjump/json-schema/draft-07";
77
import "@hyperjump/json-schema/draft-06";
88
import "@hyperjump/json-schema/draft-04";
9+
import "@hyperjump/json-schema/openapi-3-0";
10+
import "@hyperjump/json-schema/openapi-3-1";
911
import { BASIC } from "@hyperjump/json-schema/experimental";
1012
import { TestCoverageEvaluationPlugin } from "../test-coverage-evaluation-plugin.js";
1113

@@ -57,3 +59,5 @@ export const matchJsonSchema = async (instance, uriOrSchema) => {
5759
};
5860

5961
export const toMatchJsonSchema = matchJsonSchema;
62+
export { registerSchema, unregisterSchema } from "@hyperjump/json-schema/draft-2020-12";
63+
export { loadDialect, defineVocabulary, addKeyword } from "@hyperjump/json-schema/experimental";

src/vitest/matchers.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ declare module "vitest" {
77
toMatchJsonSchema: (uriOrSchema: string | SchemaObject | boolean) => Promise<R>;
88
}
99
}
10+
11+
export * from "./json-schema-matcher.d.ts";

src/vitest/matchers.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ expect.extend({
55
matchJsonSchema: matchJsonSchema,
66
toMatchJsonSchema: matchJsonSchema
77
});
8+
9+
export * from "./json-schema-matcher.js";

0 commit comments

Comments
 (0)