YousefED / typescript-json-schema

Generate json-schema from your Typescript sources
BSD 3-Clause "New" or "Revised" License
3.17k stars 323 forks source link

Generated JSON schema contains an array prototype #573

Open neen-psk opened 1 year ago

neen-psk commented 1 year ago

We are using the JsonValue type from @angular-devkit/core which looks like this

export interface JsonArray extends Array<JsonValue> {
}
export interface JsonObject {
    [prop: string]: JsonValue;
}
export type JsonValue = boolean | string | number | JsonArray | JsonObject | null;

The JSON schema was correctly generated up to version 0.59.0, but starting from version 0.60.0, an array prototype began to be included in the generated schema. Is it possible to avoid this kind of noise?

             {
               "additionalProperties": false,
               "patternProperties": { "^[0-9]+$": { "$ref": "#/definitions/JsonValue" } },
+              "properties": {
+                "__@unscopables@380": {
+                  "additionalProperties": false,
+                  "patternProperties": { "^[0-9]+$": { "type": "boolean" } },
+                  "properties": {
+                    "__@iterator@378": { "type": "boolean" },
+                    "__@unscopables@380": { "type": "boolean" },
+                    "at": {
+                      "description": "Takes an integer value and returns the item at that index,\nallowing for positive and negative integers.\nNegative integers count back from the last item in the array.",
+                      "type": "boolean"
+                    },
+                    "concat": { "type": "boolean" },
+                    "copyWithin": { "type": "boolean" },
+                    "entries": { "type": "boolean" },
+                    "every": { "type": "boolean" },
+                    "fill": { "type": "boolean" },
+                    "filter": { "type": "boolean" },
+                    "find": { "type": "boolean" },
+                    "findIndex": { "type": "boolean" },
+                    "flat": { "type": "boolean" },
+                    "flatMap": { "type": "boolean" },
+                    "forEach": { "type": "boolean" },
+                    "includes": { "type": "boolean" },
+                    "indexOf": { "type": "boolean" },
+                    "join": { "type": "boolean" },
+                    "keys": { "type": "boolean" },
+                    "lastIndexOf": { "type": "boolean" },
+                    "length": { "type": "boolean" },
+                    "map": { "type": "boolean" },
+                    "pop": { "type": "boolean" },
+                    "push": { "type": "boolean" },
+                    "reduce": { "type": "boolean" },
+                    "reduceRight": { "type": "boolean" },
+                    "reverse": { "type": "boolean" },
+                    "shift": { "type": "boolean" },
+                    "slice": { "type": "boolean" },
+                    "some": { "type": "boolean" },
+                    "sort": { "type": "boolean" },
+                    "splice": { "type": "boolean" },
+                    "toLocaleString": { "type": "boolean" },
+                    "toString": { "type": "boolean" },
+                    "unshift": { "type": "boolean" },
+                    "values": { "type": "boolean" }
+                  },
+                  "type": "object"
+                },
+                "length": { "type": "number" }
+              },
+              "required": ["__@unscopables@380", "length"],
               "type": "object"
             },
             { "$ref": "#/definitions/JsonObject" },