YousefED / typescript-json-schema

Generate json-schema from your Typescript sources
BSD 3-Clause "New" or "Revised" License
3.17k stars 323 forks source link

How to generate title in human readable format? #559

Open FreePhoenix888 opened 1 year ago

FreePhoenix888 commented 1 year ago

Code

export interface Abc {
  firstName: string
}

Expected

freephoenix888@freephoenix888:~/Programming/deep/firebase-push-notification$ typescript-json-schema ./src/push-notification.ts "Abc" --titles
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "properties": {
        "firstName": {
            "title": "First name",
            "type": "string"
        }
    },
    "type": "object"
}

Actual

freephoenix888@freephoenix888:~/Programming/deep/firebase-push-notification$ typescript-json-schema ./src/push-notification.ts "Abc" --titles
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "properties": {
        "firstName": {
            "title": "firstName",
            "type": "string"
        }
    },
    "type": "object"
}

Additional Info

Why do I need this: I want to use this generated JSON-Schema for form generation using react-jsonschema-form

FreePhoenix888 commented 1 year ago

@YousefED

FreePhoenix888 commented 1 year ago

@domoritz

FreePhoenix888 commented 1 year ago

We can use capitalCase from https://www.npmjs.com/package/case-anything

leqwasd commented 1 year ago

Add JSDoc comment

export interface Abc {
    /**
     * First name
     */
    firstName: string;
}
acollazo25 commented 9 months ago

Remove --titles parameter from command and add @title JSDoc comment.

export interface Abc {
    /**
     * @title First name
     */
    firstName: string;
}