-
Notifications
You must be signed in to change notification settings - Fork 373
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
Improve schemaTypeIs tester to use deriveType #1354
Improve schemaTypeIs tester to use deriveType #1354
Conversation
eneufeld
commented
Apr 29, 2019
- Update AllOfRenderer rank to 3
- Update AnyOfRenderer rank to 3
* Rename deriveType to deriveTypes * schemaTypeIs is working for array types * Update AllOfRenderer rank to 3 * Update AnyOfRenderer rank to 3 Fixes eclipsesource#1355
68627c3
to
deb88ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the changes look fine, but I'd probably rename isValidType
. Also there' an outdated comment.
packages/core/src/util/index.ts
Outdated
*/ | ||
const isUnionType = (jsonSchema: JsonSchema): boolean => | ||
!isEmpty(jsonSchema) && !isEmpty(jsonSchema.type) && isArray(jsonSchema.type); | ||
const isValidType = (jsonSchema: JsonSchema, expected: string): boolean => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd propose to rename this to hasType
, matchesType
or similiar.
}); | ||
|
||
test('derive type with type - union', t => { | ||
const schema: JsonSchema = { | ||
type: ['string', 'number'] | ||
}; | ||
t.is(deriveTypes(schema).length, 2); | ||
// we just take the first, as derive type returns exactly one value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is not accurate anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!