Yet another TypeScript generator for OpenAPI specifications.
What this package is intended to do:
- support multiple input formats
- support output formatting
- only generate most necessary types/interfaces, utils
What this package won't do:
- it won't generate code which relies on transitive dependencies (e.g.: axios, or browser API-s)
- it won't support all of the possible exotic features of OpenAPI, like composition for multiple objects
- it won't generate sophisticated classes and services
For examples please check the examples folder.
Since OpenAPI does not specify any mandatory field which would serve as a unique identifier for Paths, the current algorithm produces files names (converted to Pascal Case) from:
- If available:
operationId
- Otherwise if available:
summary
- As a fallback, if none of the above are available we create a special name.
Please refer to: namings.js: operationName() for full details.
sott generate $(SOURCE_FOR_SPEC_FILE)
SOURCE_FOR_SPEC_FILE
can be either a file system path, or a http(s) URL. Supported file types:
YAML, JSON.
Target folder where sources will be generated.
- Type: string
- Default value: ./generated-sources
Path to prettier configuration file (JSON).
- Type: string
- Default configuration object:
{
"parser": "typescript",
"endOfLine": "lf"
}
provided values are "spread onto" the default(s), so there is no need to duplicate options.
Deeply nested object types will not be mapped recursively, the second level of any schema with a
type of object
will be mapped as any
.
Composition is not supported. Instead currently the generator will produce interfaces which will
extend a base, and every other possible type definition will be ignored (only using first allOf
).
This is an implementation limitation. Maybe in the future composition will be supported.
Removed "example" section from the definition, because it contained illegal syntax, and did not even comply with their own schema.