ts-json-schema-generator
ts-json-schema-generator copied to clipboard
Missing features
An inventorization of features that are missing in this module (for #101). There might be things that you (@domoritz) don't want to add, or that I missed some. If so, please tell me and I will add them to the list.
Missing features
- [x] Conditional types (#105 (PR), #100, #93, #71)
- [x] Selecting all types with a '*' (#117)
- [x] Programmatic usage (at least documentation on it)
Nice additions
- [ ] Selecting all type in a namespace using
NamespaceName.*
(YousefED#249) - [x] Configuration inference (YousefED#290, #103)
- [ ] Indentation option for output file (YousefED#226)
- [ ] Manually overriding schema generation for certain types to surmount shortcomings in the generator (I'm working on a proper proposal for this)
Sounds good. Let me also mention that Vega-Lite would benefit from having support for conditionals so I am very much looking forward to having support for it.
It seems that methods / function declarations are not exported.
Yes, we intentionally don't support functions. See for some reasons why not: https://github.com/vega/ts-json-schema-generator/issues/98
Ok, that's clear, thank you for the quick response.
@domoritz Is there a way for the schema generator to ignore the interfaces/types which have function definitions in them? I have one such interface and it is exported
too.
- If it helps, I can contribute to the third task (Programatic Use documentation). Was able to set up the programmatic use for my project, so should be quick to explain the usage in the README.
- The README is also missing an option on
output
file path.
It would be nice to have the option to add schema $id
similarly to https://github.com/YousefED/typescript-json-schema. For example, https://github.com/ajv-validator/ajv needs it.
@roper79 I agree having this natively would be a good thing. For your information though, I successfully achieved it by annotating types with @$id
and adding the --validationKeywords "\$id"
option to the CLI.
I'm happy to review a pull request.
What about Required<Type>? https://www.typescriptlang.org/docs/handbook/utility-types.html#requiredtype Currently this not work:
export interface Node = {
name?: string;
key?: string
// Many other properties
}
// force key to be required
export type Wrapper {
node: Omit<Node, 'key'> & Required<Pick<Node, 'key'>>;
}
Workaround:
export type Wrapper {
node: Omit<Node, 'key'> & {key: string}>;
}
But this is not very nice in scale.