Created
February 28, 2020 10:47
-
-
Save robertdempsey/14cb3b537e42fa4bfa869c08b8b2405d to your computer and use it in GitHub Desktop.
Example Typescript input for ts-json-schema-generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface MyBaseObject { | |
/** | |
* This is a number. We can set the max and min like so | |
* @minimum 3 | |
* @maximum 9 | |
*/ | |
number: number; | |
/** | |
* This is a string. We can set the maxLength like so | |
* @maxLength 20 | |
*/ | |
string: string; | |
} | |
export interface MyObject extends MyBaseObject { | |
/** | |
* This is an array. We can set the maxItems using | |
* @maxItems 99 | |
*/ | |
array: MyBaseObject[] | |
/** | |
* This is an object | |
*/ | |
object: MyBaseObject; | |
/** | |
* We can set optional properties like so | |
*/ | |
notRequired?: boolean; | |
/** | |
* This will generate a property of type string with an enum with the below possible values | |
*/ | |
setOfKnownStrings: "one" | "two" | "three"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment