Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External reference breaks arrays #1879

Closed
wburgers opened this issue Feb 29, 2024 · 1 comment
Closed

External reference breaks arrays #1879

wburgers opened this issue Feb 29, 2024 · 1 comment
Labels

Comments

@wburgers
Copy link

wburgers commented Feb 29, 2024

Suppose we have the following types:

fileA:

export interface ClassA {
  property: string;
}

fileB:

export interface ClassB {
  /**
     * @ref ./ClassA.json
     */
  array: ClassA[];
}

Then the output becomes:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "additionalProperties": false,
    "definitions": {},
    "properties": {
        "array": {
            "$ref": "./ClassA.json"
        },
    },
    "required": [
        "array",
    ],
    "type": "object"
}

Where I would expect:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "additionalProperties": false,
    "definitions": {},
    "properties": {
        "array": {
            "items": {
                "$ref": "./ClassA.json"
            },
            "type": "array"
        },
    },
    "required": [
        "array",
    ],
    "type": "object"
}

Is there a way to get the right output as expected?
Am I using the generator incorrectly?

@arthurfiorette
Copy link
Collaborator

@ref overrides the $ref field, it does not resolves imports for you. You need to manually use import type { ClassA } from "./file";` to make it work, otherwise its a type error.

@arthurfiorette arthurfiorette closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants