Skip to content

Exception when using array that has enums specifying order of elements in an array #219

@Dr-Irv

Description

@Dr-Irv

What did you do

jsonschema2md -e json -d foo -o docs

(File mod.json in directory foo)

What did you expect to happen

No errors

What happened

Got a stack trace:

loading 1 schemas
writing schemas
writing schemas to c:\Code\NBCU\GitRepo\SpringBootServant\NBCU Python Servant\out
writing README
building readme
writing documentation
generating markdown
(node:6660) UnhandledPromiseRejectionWarning: TypeError: Cannot convert object to primitive value
    at constraints.push.schema.(anonymous function).map.value (C:\Anaconda3\node_modules\@adobe\jsonschema2md\lib\markdownBuilder.js:554:31)
    at Proxy.map (<anonymous>)
    at makeconstraintssection (C:\Anaconda3\node_modules\@adobe\jsonschema2md\lib\markdownBuilder.js:552:34)
    at Object.entries.map (C:\Anaconda3\node_modules\@adobe\jsonschema2md\lib\markdownBuilder.js:729:14)
    at Array.map (<anonymous>)
    at makeproplist (C:\Anaconda3\node_modules\@adobe\jsonschema2md\lib\markdownBuilder.js:719:54)
    at makeproperties (C:\Anaconda3\node_modules\@adobe\jsonschema2md\lib\markdownBuilder.js:833:12)
    at foldl (C:\Anaconda3\node_modules\@adobe\jsonschema2md\lib\markdownBuilder.js:857:10)
    at each (C:\Anaconda3\node_modules\@adobe\jsonschema2md\node_modules\ferrum\src\sequence.js:1014:12)
    at curry (C:\Anaconda3\node_modules\@adobe\jsonschema2md\node_modules\ferrum\src\sequence.js:604:5)
(node:6660) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6660) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
c:\Code\NBCU\GitRepo\SpringBootServant\NBCU Python Servant\docs\README.md created

What's your environment

  • Operating System: Window s10
  • node.js version: 10.13.0

Do you have example files:

For this schema

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "file://foo/mod.json",
  "title": "MI",
  "description": "Specification for input JSON",
  "type": "object",
  "properties": {
    "columns": {
      "title": "Columns",
      "enum": [["P", "M"]],
      "type": "array"
    }
  },
  "required": ["columns"]
}

No markdown is produced.

Note - it seems the issue is that the schema we created is specifying that there is an array with values in a specified order. This is valid JSON Schema.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions