Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide the tsdoc/typedoc/jsdoc proper commentaries to generated interfaces based on schema title and/or schema description. #10

Closed
majo44 opened this issue Apr 27, 2016 · 2 comments

Comments

@majo44
Copy link

majo44 commented Apr 27, 2016

Currently the commentaries are based only on description.

Eg.
For schema:

{
  "title": "My Object",
  "description": "Some custom object",
  "type": "object",
  "properties": {
       "bar" : {
          "title": "Some property",
          "description": "Some property description",
          "type": "string"
       }
   }
}

We have:

/*
    Some custom object
  */
export interface MyObject {
  bar?: string; // Some property description
  [k: string]: any;
}

It will be nice to have:

/**
 * Some custom object.
 */
export interface MyObject {
 /**
   * Some property.
   * Some property description.
   */
  bar?: string;
  [k: string]: any;
}
@majo44 majo44 changed the title Provide the tsdoc proper commentaries to generated interfaces based on schema title and/or schema description. Provide the tsdoc/typedoc/jsdoc proper commentaries to generated interfaces based on schema title and/or schema description. Apr 27, 2016
@bcherny
Copy link
Owner

bcherny commented Apr 30, 2016

Good idea - how about a heuristic:

  • If a property only has a description, use an inline comment
  • If a property has both a description and a title, use a block comment

Feel free to submit a PR, otherwise I'll get to this eventually.

@bcherny
Copy link
Owner

bcherny commented Sep 27, 2016

If description is set, it will produce a multi-line comment (newlines are supported).
If title is set, it will generate a type alias (see https://github.com/bcherny/json-schema-to-typescript/blob/master/test/cases/named-property.ts).

Both work with intellisense.

@bcherny bcherny closed this as completed Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants