json-schema-to-typescript icon indicating copy to clipboard operation
json-schema-to-typescript copied to clipboard

Array `items` object with `tsEnumNames` needs a `title`

Open stefanpl opened this issue 4 years ago • 2 comments

If you remove the title inside properties.namedEnum.items from the test/e2e/arrayOfEnum.ts, an error will be thrown:

TypeError {
  message: 'Cannot read property \'endsWith\' of undefined',
}
> src/generator.ts:182:21

This looks like a bug to me, as the items object in json schema is not required to have a title.

If this is indeed a design decision/limitation, it would be nice to properly document it. The error is very opaque, it took me some time to see what's the problem with my code.

Thanks already for taking a look, and of course for providing this really helpful package 🎉

stefanpl avatar Sep 15 '21 12:09 stefanpl

+1 Didn't even know you could add a title to the items object! Thanks for raising this @stefanpl as I now know adding the title on-the-fly provides a temporary solution.

PerttiK avatar Sep 21 '21 21:09 PerttiK

Just ran into this, thanks for posting the workaround

rcorral avatar Jul 27 '22 23:07 rcorral