Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnamed enums in array items throw #530

Closed
Joshua-Schecker opened this issue Jun 7, 2023 · 1 comment
Closed

Unnamed enums in array items throw #530

Joshua-Schecker opened this issue Jun 7, 2023 · 1 comment
Labels

Comments

@Joshua-Schecker
Copy link

I would like use the tsEnumNames property when defining the items property of an array of enum values; however it fails.
If it's not a supported use case, then it would be nice to put this in the documentation.

Example schema:

{
  "type": "object",
  "properties": {
    "foo": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["BAR", "BAZ"],
        "enumNames": ["bar", "baz"],
        "tsEnumNames": ["BAR", "BAZ"]
      }
    },
    "title": "foo"
  }
}

results in the following error:

  TypeError: Cannot read properties of undefined (reading 'endsWith')
      at /Users/<username>/Library/Application Support/fnm/node-versions/v18.12.1/installation/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:161:29
      at generateRawType (/Users/<username>/Library/Application Support/fnm/node-versions/v18.12.1/installation/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:162:15)
      at generateTypeUnmemoized (/Users/<username>/Library/Application Support/fnm/node-versions/v18.12.1/installation/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:143:16)
      at memoized (/Users/<username>/Library/Application Support/fnm/node-versions/v18.12.1/installation/lib/node_modules/json-schema-to-typescript/node_modules/lodash/lodash.js:10620:27)
      at /Users/<username>/Library/Application Support/fnm/node-versions/v18.12.1/installation/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:273:72
      at Array.map (<anonymous>)
      at generateInterface (/Users/<username>/Library/Application Support/fnm/node-versions/v18.12.1/installation/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:271:14)
      at generateStandaloneInterface (/Users/<username>/Library/Application Support/fnm/node-versions/v18.12.1/installation/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:309:9)
      at declareNamedInterfaces (/Users/<username>/Library/Application Support/fnm/node-versions/v18.12.1/installation/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:71:21)
      at generate (/Users/<username>/Library/Application Support/fnm/node-versions/v18.12.1/installation/lib/node_modules/json-schema-to-typescript/dist/src/generator.js:22:9)
]
@bcherny bcherny changed the title Array of enums is not compatible with tsEnumNames Unnamed enums in array items throw Jun 10, 2023
@bcherny bcherny added the bug label Jun 10, 2023
@bcherny
Copy link
Owner

bcherny commented Jun 10, 2023

Published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants