Skip to content

Schema not generated for types exported from module #241

@sabrehagen

Description

@sabrehagen

Hi,

I'm finding that types exported from an external module do not have schemas generated for them. I have a types library @stemn/types and a schemas library @stemn/schemas.

My intention was to generate my schemas from my types library by exporting my types as so

// schemas.ts
export { IPipelineYmlV1 } from '@stemn/types';

Running

yarn typescript-json-schema schemas.ts IPipelineYmlV1

produces

Error: type IPipelineYmlV1 not found
    at JsonSchemaGenerator.getSchemaForSymbol (/node_modules/typescript-json-schema/typescript-json-schema.js:764:19)

Further testing showed when an imported type is extended its properties do not show in the produced schema. For example

// schemas.ts

import { IPipelineYmlV1 } from '@stemn/types';

export interface IPipelineYmlV2 extends IPipelineYmlV1 {
    child: boolean;
}

run with

yarn typescript-json-schema schemas.ts '*'

produces

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "IPipelineYmlV2": {
            "properties": {
                "child": {
                    "type": "boolean"
                }
            },
            "type": "object"
        }
    }
}

Is this expected functionality? If so, is there something I can do to have schemas generated for a directly exported type? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions