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

Improve schemaTypeIs tester to use deriveType #1354

Merged
merged 2 commits into from
May 3, 2019

Conversation

eneufeld
Copy link
Member

  • 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
@coveralls
Copy link

coveralls commented Apr 29, 2019

Coverage Status

Coverage increased (+0.2%) to 85.581% when pulling 1ff3b36 on eneufeld:fix/allOf-anyOf-testers into 6580c02 on eclipsesource:master.

Copy link
Contributor

@edgarmueller edgarmueller left a 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.

*/
const isUnionType = (jsonSchema: JsonSchema): boolean =>
!isEmpty(jsonSchema) && !isEmpty(jsonSchema.type) && isArray(jsonSchema.type);
const isValidType = (jsonSchema: JsonSchema, expected: string): boolean => {
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

@edgarmueller edgarmueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@edgarmueller edgarmueller added this to the 2.3.0 milestone May 3, 2019
@edgarmueller edgarmueller merged commit 5797369 into eclipsesource:master May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants