ts-json-schema-generator icon indicating copy to clipboard operation
ts-json-schema-generator copied to clipboard

Missing features

Open HoldYourWaffle opened this issue 5 years ago • 10 comments

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)

HoldYourWaffle avatar Jun 01 '19 08:06 HoldYourWaffle

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.

domoritz avatar Jun 01 '19 17:06 domoritz

It seems that methods / function declarations are not exported.

hansmbakker avatar Aug 11 '19 11:08 hansmbakker

Yes, we intentionally don't support functions. See for some reasons why not: https://github.com/vega/ts-json-schema-generator/issues/98

domoritz avatar Aug 11 '19 11:08 domoritz

Ok, that's clear, thank you for the quick response.

hansmbakker avatar Aug 11 '19 11:08 hansmbakker

@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.

maneetgoyal avatar Dec 31 '19 01:12 maneetgoyal

  • 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.

maneetgoyal avatar Jan 01 '20 07:01 maneetgoyal

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 avatar Aug 31 '20 10:08 roper79

@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.

antmarot avatar Oct 01 '20 07:10 antmarot

I'm happy to review a pull request.

domoritz avatar Oct 01 '20 15:10 domoritz

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.

Halynsky avatar Sep 12 '23 14:09 Halynsky