YousefED / typescript-json-schema

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

How to generate title in human readable format? #559

Open FreePhoenix888 opened 11 months ago

FreePhoenix888 commented 11 months 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 11 months ago

@YousefED

FreePhoenix888 commented 11 months ago

@domoritz

FreePhoenix888 commented 11 months ago

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

leqwasd commented 9 months ago

Add JSDoc comment

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

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

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