bcherny/json-schema-to-typescript

A schema with a field called "description" throws "TypeError: comment.split is not a function"

timfarrar opened this issue · 1 comments

compiling this schema:

  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "definitions": {
    "Thing_1": {
      "type": "object",
      "properties": {
        "schema_version": {
          "type": "integer",
          "minimum": 0,
          "maximum": 18446744073709551615
        },
        "short_name": {
          "type": "string"
        },
        "long_name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      },
      "required": [
        "short_name"
      ],
      "additionalProperties": false
    }
  },
  "type": "object",
  "properties": {
    "$ref": "#/definitions/Thing_1"
  }
}

results in this error:

TypeError: comment.split is not a function
at generateComment (<path_redacted>/node_modules/json-schema-to-typescript/dist/src/generator.js:288:57)
at <path_redacted>/node_modules/json-schema-to-typescript/dist/src/generator.js:277:73
at Array.map ()
at generateInterface (<path_redacted>/node_modules/json-schema-to-typescript/dist/src/generator.js:275:14)
at generateStandaloneInterface (<path_redacted>/node_modules/json-schema-to-typescript/dist/src/generator.js:309:9)
at declareNamedInterfaces (<path_redacted>/node_modules/json-schema-to-typescript/dist/src/generator.js:71:21)
at generate (<path_redacted>/node_modules/json-schema-to-typescript/dist/src/generator.js:22:9)
at <path_redacted>/node_modules/json-schema-to-typescript/dist/src/index.js:161:58
at step (<path_redacted>/node_modules/json-schema-to-typescript/dist/src/index.js:59:23)
at Object.next (<path_redacted>/node_modules/json-schema-to-typescript/dist/src/index.js:40:53)

However:

  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "definitions": {
    "Thing_1": {
      "type": "object",
      "properties": {
        "schema_version": {
          "type": "integer",
          "minimum": 0,
          "maximum": 18446744073709551615
        },
        "short_name": {
          "type": "string"
        },
        "long_name": {
          "type": "string"
        },
        "not_a_description": {
          "type": "string"
        }
      },
      "required": [
        "short_name"
      ],
      "additionalProperties": false
    }
  },
  "type": "object",
  "properties": {
    "$ref": "#/definitions/Thing_1"
  }
}

does not.

Published 13.1.1