sagold / json-schema-library

Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation
MIT License
164 stars 19 forks source link

Unable to iterate over schema using eachSchema #13

Closed fizan2904 closed 2 years ago

fizan2904 commented 3 years ago

I have used almost every utility in this library, and I like it very much.

While using the eachSchema method to iterate over schema I faced an issue. It will iterate only if the type keyword is not an array.

eg: { type: 'string' } works fine but { type: ['string', 'null'] } doesn't.

https://github.com/sagold/json-schema-library/blob/master/lib/schema/getTypeId.ts at line 24 if (types[schema.type]) { schema.type is assumed not to be an array everytime

sagold commented 2 years ago

Hi fizan,

thank you for the feedback. With version 6.0.0 eachSchema iterates over schemas defined with an type-array. Please pay attention to api changes.

Are there any json-schema helpers you are missing here?