typescript-json-schema icon indicating copy to clipboard operation
typescript-json-schema copied to clipboard

type alias lose annotations

Open nidi3 opened this issue 8 years ago • 3 comments

/**
 * @format uuid
 */
export type UUID=string

interface A{
    u:UUID
}

gives

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
        "A": {
            "properties": {
                "u": {
                    "format": "uuid",
                    "type": "string"
                }
            },
            "type": "object"
        },
        "UUID": {
            "type": "string"
        }
    }
}

I'd expect format: uuid in the UUID definition. This prevents importing annotated type aliases, which would be a really cool thing.

nidi3 avatar Feb 01 '17 10:02 nidi3

This is odd. Can you send a pull request with this test case so we can look into it? Maybe you can even take a stab at a fix. The code for this tool is actually not that large.

domoritz avatar Feb 01 '17 18:02 domoritz

I seem to see similar; format doesn't get added to the schema.

Is there a workaround?

/**
 * An EDTF level 0 or 1 date, with optional seasonal range.
 *
 * See https://github.com/retorquere/json-schema-edtf
 *
 * @format edtf/level-1+season-intervals
 */
export type EDTFDATE = string | null | undefined;

bdarcus avatar May 06 '23 12:05 bdarcus

Any updates on this?

Flynamic avatar Jul 22 '24 17:07 Flynamic