bcherny/json-schema-to-typescript

description conversion to comments may break if not escaped

Open

#166 opened on Jun 6, 2018

View on GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (449 forks)github user discovery
buggood first issuehelp wanted

Repository metrics

Stars
 (3,302 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

{
    "type": "object",
    "description": "thing",
    "properties": {
      "oops": {
        "type": "object",
        "description": "oops I did it again */"
      }
    },
    "minProperties": 1,
    "additionalProperties": false
}

Because the description is directly converted to a javascript comment inside a /** */ the */ in the JSON description causes an early termination of the comment and breaks the conversion, causing an error like:

± ./node_modules/.bin/json2ts /tmp/test.json        Property or signature expected. (13:2)
  11 | /**
  12 |  * oops I did it again */
> 13 |  */
     |  ^
  14 | oops?: {
  15 | [k: string]: any
  16 | }% 

version

± ./node_modules/.bin/json2ts --help

json-schema-to-typescript 5.5.0
...

Contributor guide