Skip to content

Commit

Permalink
feat(@ngtools/json-schema): support null data type
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin committed Feb 8, 2018
1 parent 57d7c16 commit 8ff9533
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/@ngtools/json-schema/src/schema-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export abstract class NonLeafSchemaTreeNode<T> extends SchemaTreeNode<T> {
case 'boolean': Klass = BooleanSchemaTreeNode; break;
case 'number': Klass = NumberSchemaTreeNode; break;
case 'integer': Klass = IntegerSchemaTreeNode; break;
case 'null': Klass = NullSchemaTreeNode; break;

case 'enum': Klass = EnumSchemaTreeNode; break;
case 'oneOf': Klass = OneOfSchemaTreeNode; break;
Expand Down Expand Up @@ -462,6 +463,13 @@ class StringSchemaTreeNode extends LeafSchemaTreeNode<string> {
get tsType() { return String; }
}

class NullSchemaTreeNode extends LeafSchemaTreeNode<string> {
isCompatible(v: any) { return v == undefined || v == null; }
convert(_v: any): null { return null; }
get type() { return 'null'; }
get tsType() { return Object; }
}


class EnumSchemaTreeNode extends LeafSchemaTreeNode<any> {
constructor(metaData: TreeNodeConstructorArgument<any>) {
Expand Down

0 comments on commit 8ff9533

Please sign in to comment.