question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema not generated for types exported from module

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
domoritzcommented, Nov 19, 2018

Interesting. I wonder whether https://github.com/vega/ts-json-schema-generator picks up external types more cleanly.

1reaction
sabrehagencommented, Aug 26, 2018

I created a minimum viable tsconfig.json that includes all files - no luck.

Read more comments on GitHub >

github_iconTop Results From Across the Web

An issue with Nestjs mongoose module after installation
d.ts:2:44 - error TS2694: Namespace '"mongoose"' has no exported member 'SchemaTypeOpts'. export declare type PropOptions = mongoose.
Read more >
ytt - Export Schema in OpenAPI Format - Carvel tools
Working Example · Exported Properties. title; type; additionalProperties; nullable; deprecated; description; x-example-description; example; default · Known ...
Read more >
Generating client types in Pothos GraphQL
The first thing you will need is a file that exports your built schema. The schema should be exported as schema or as...
Read more >
makeSchema - GraphQL Nexus
2import * as types from './allNexusTypes'. 3. 4export const schema = makeSchema({. 5 types, ... If you do not wish to generate one...
Read more >
schema field - GraphQL Code Generator
exports = buildSchema(/* GraphQL */ ` type MyType { foo: String! } type Query { myType: MyType! } `).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found