Skip to content

Instantly share code, notes, and snippets.

@moodysalem
Created February 8, 2018 19:51
Show Gist options
  • Save moodysalem/6458e7a0056c1a27e2c1bfb83afcefe8 to your computer and use it in GitHub Desktop.
Save moodysalem/6458e7a0056c1a27e2c1bfb83afcefe8 to your computer and use it in GitHub Desktop.
TypeScript type interfaces for Swagger Models
interface IDataType {
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
readOnly?: true;
writeOnly?: true;
}
interface IStringType extends IDataType {
type: 'string';
format?: 'date' | 'date-time' | 'password' | 'byte' | 'binary' | 'uuid' | 'email' | 'uri' | 'hostname' | 'ipv4' | 'ipv6';
}
interface INumberType extends IDataType {
type: 'number';
format?: 'float' | 'double';
minimum?: number;
maximum?: number;
}
interface IIntegerType extends IDataType {
type: 'integer';
format?: 'int32' | 'int64';
minimum?: number;
maximum?: number;
}
interface IBooleanType extends IDataType {
type: 'boolean';
}
interface IArrayType extends IDataType {
type: 'array';
items: IDataType;
}
interface IObjectType extends IDataType {
type: 'object';
properties: {
[key: string]: IDataType
};
required: string[];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment