Skip to content

Instantly share code, notes, and snippets.

@robertdempsey
Created February 28, 2020 10:47
Show Gist options
  • Save robertdempsey/14cb3b537e42fa4bfa869c08b8b2405d to your computer and use it in GitHub Desktop.
Save robertdempsey/14cb3b537e42fa4bfa869c08b8b2405d to your computer and use it in GitHub Desktop.
Example Typescript input for ts-json-schema-generator
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