-
Notifications
You must be signed in to change notification settings - Fork 45
fix: array subtype #46
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
Conversation
P0lip
left a comment
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.
Looking okay. I'd just extend inferType fn.
export function inferType(node: JSONSchema4): JSONSchema4TypeName | undefined {
if ('properties' in node) {
return SchemaKind.Object;
}
if ('items' in node) {
return SchemaKind.Array;
}
if ('type' in node) {
return node.type;
}
return;
}
src/utils/getNodeType.ts
Outdated
| import { JSONSchema4, JSONSchema4TypeName } from 'json-schema'; | ||
| import { inferType } from './inferType'; | ||
|
|
||
| export function getNodeType(node: JSONSchema4): JSONSchema4TypeName | JSONSchema4TypeName[] | undefined { |
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.
Let's just extend inferType function.
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.
That was actually my first intention but thought it might not be precise enough as it is used separately in few places in the code already.
I'll move it there. But if so shouldn't type be checked before properties and items?
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.
Yeah, it could be moved to the top.
| import { Property, Types } from '../shared'; | ||
|
|
||
| describe('Property component', () => { | ||
| it('should render Types with propper type and subtype', () => { |
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.
👍
P0lip
left a comment
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.
Good job.
|
🎉 This PR is included in version 2.6.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #71
Changes: