Skip to content

Commit

Permalink
add: global setting to deactivate __oneOfIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
sagold committed Dec 2, 2024
1 parent cbac0f1 commit 1fdfdb1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/config/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export default {
DECLARATOR_ONEOF: "oneOfProperty",
/** set to false to not set __oneOfIndex on returned schema */
EXPOSE_ONE_OF_INDEX: true,
GET_TEMPLATE_RECURSION_LIMIT: 1,
propertyBlacklist: ["_id"],
templateDefaultOptions: {
Expand Down
4 changes: 2 additions & 2 deletions lib/features/oneOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { isObject } from "../utils/isObject";
import { JsonValidator } from "../validation/type";
import { SchemaNode } from "../schemaNode";

const { DECLARATOR_ONEOF } = settings;
const { DECLARATOR_ONEOF, EXPOSE_ONE_OF_INDEX } = settings;

function setOneOfOrigin(schema: JsonSchema, index: number) {
if (isObject(schema)) {
if (EXPOSE_ONE_OF_INDEX && isObject(schema)) {
schema.__oneOfIndex = index;
}
}
Expand Down

0 comments on commit 1fdfdb1

Please sign in to comment.