Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sagold committed Dec 1, 2024
1 parent 662f00e commit 19fa477
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ What follows is a description of the main draft methods.
**Currently unsupported core features:**

- `$vocabulary` - meta-schemas are not parsed for enabled features
- `unevaluatedItems: uncle-schema` - evaluation of uncle-schemas is not supported. Properties will be return as evaluated
- `unevaluatedProperties: uncle-schema` - evaluation of uncle-schemas is not supported. Properties will be return as evaluated
- `unevaluatedItems: uncle-schema` - evaluation of uncle-schemas is not supported. Properties will be returned as evaluated
- `unevaluatedProperties: uncle-schema` - evaluation of uncle-schemas is not supported. Properties will be returned as evaluated

For further details see [draft2019-09 tests](https://github.com/sagold/json-schema-library/blob/main/test/spec/v2019-09/draft2019-09.test.ts)

Expand Down
13 changes: 9 additions & 4 deletions lib/getChildSchemaSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isJsonError, JsonError, JsonSchema } from "./types";
* could be added at the given property (e.g. item-index), thus an array of options is returned. In all other cases
* a list with a single item will be returned
*
* @param draft - draft to use
* @param draft - draft to use
* @param property - parent schema of following property
* @param [schema] - parent schema of following property
* @return
Expand All @@ -20,12 +20,17 @@ export default function getChildSchemaSelection(
return schema.oneOf.map((item: JsonSchema) => draft.createNode(item).resolveRef().schema);
}
if (schema.items?.oneOf) {
return schema.items.oneOf.map((item: JsonSchema) => draft.createNode(item).resolveRef().schema);
return schema.items.oneOf.map(
(item: JsonSchema) => draft.createNode(item).resolveRef().schema
);
}
if (Array.isArray(schema.items) && schema.items.length <= +property) {
return [];
}
const node = draft.step(draft.createNode(schema), property, {});
if (isJsonError(node)) {
return node;
const error: JsonError = node;
return error;
}

return [node.schema];
}
2 changes: 0 additions & 2 deletions test/unit/createSchemaOf.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { expect } from "chai";
import createSchemaOf from "../../lib/createSchemaOf";


describe("createSchemaOf", () => {

it("should add type 'object' of data to schema", () => {
const res = createSchemaOf({});
expect(res.type).to.eq("object");
Expand Down

0 comments on commit 19fa477

Please sign in to comment.