Genetate json scheme, protobuf file, graphQL/mongoose(alpha) schema, reasonml(alpha)/ocaml(alpha)/rust(alpha) types and swagger doc from typescript types.
- type literal
- interface
- type union
- interface extends
- type intersection
- type array
- tagged field
- marked as more precise type
- enum
- class
- class extends
- muitiple files
- function / method
- variable statement
yarn global add types-as-schema
types-as-schema demo/types.ts --json demo/ --protobuf demo/types.proto --graphql demo/types.gql --graphql-root-type demo/root-type.ts --reason demo/types.re --ocaml demo/types.ml --rust demo/types.rs --debug demo/debug.json
parameters | description |
---|---|
--json |
directory for generated json files |
--protobuf |
generated protobuf file |
--graphql |
generated graphql schema file |
--graphql-root-type |
generated graphql root type |
--reason |
generated reason types file |
--ocaml |
generated ocaml types file |
--rust |
generated rust types file |
--mongoose |
generated mongoose schema file |
--swagger |
generated swagger json file |
--swagger-base |
swagger json file that generation based on |
--debug |
generated file with debug information in it |
--watch or -w |
watch mode |
@type uint32
: settype = "uint32"
@mapValueType uint32
: more detailed type of a map type value
@tag 1
: tag or id
entry:
@entry request-protocol.json
: the entry file name
common:
@title foo
: settitle = 'foo'
@description bar
: setdescription = 'bar'
number:
@multipleOf 10
: setmultipleOf = 10
@minimum 70
: setminimum = 70
@maximum 90
: setmaximum = 90
@exclusiveMinimum 70
: setexclusiveMinimum = 70
@exclusiveMaximum 90
: setexclusiveMaximum = 90
@default 10
: setdefault = 10
string:
@minLength 10
: setminLength = 10
@maxLength 20
: setmaxLength = 20
@pattern ^[A-z]{3}$
: setpattern = ^[A-z]{3}$
@default foo
: setdefault = 'foo'
boolean:
@default true
: setdefault = true
object:
@minProperties 1
: setminProperties = 1
@maxProperties 3
: setmaxProperties = 3
@additionalProperties
: setadditionalProperties = true
array:
@uniqueItems
: setuniqueItems = true
@minItems 1
: setminItems = 1
@maxItems 10
: setmaxItems = 10
@itemType integer
: set itemtype = "integer"
number[]:
@itemMultipleOf 10
: set itemmultipleOf = 10
@itemMinimum 70
: set itemminimum = 70
@itemMaximum 90
: set itemmaximum = 90
@itemExclusiveMinimum 70
: set itemexclusiveMinimum = 70
@itemExclusiveMaximum 90
: set itemexclusiveMaximum = 90
@itemDefault 10
: set itemdefault = 10
string[]:
@itemMinLength 10
: set itemminLength = 10
@itemMaxLength 20
: set itemmaxLength = 20
@itemPattern ^[A-z]{3}$
: set itempattern = ^[A-z]{3}$
@itemDefault foo
: set itemdefault = 'foo'
boolean[]:
@itemDefault true
: set itemdefault = true
@param {string} name
: set argumentname: String!
@param {string} [name]
: set argumentname: String
@method get
: set api method@path /pet/{id}
: set api url@in query
: a parameter in aquery
,body
,header
,formData
orpath
@deprecated
: set api as deprecated api@tags pet
: set api tags, can be seperated by,
@index
: set index@unique
: set unique index@sparse
: set sparse index@select
: set select@alias index4
: set alias
type uint32 = number;
type integer = number;
type Foo = {
bar: uint32;
foo: integer;
}