Skip to content

Is there support for relative references? #129

Open
@gz-95

Description

@gz-95

Thanks for this really useful library! I was just wondering if this library supports relative references? The following is an example of what I'm trying to achieve:

import { FromSchema } from "json-schema-to-ts";

const types = {
  $id: "https://example.local/types/",
  $schema: "http://json-schema.org/draft-07/schema#",
  definitions: {
    foo: {
      $ref: "#/definitions/bar",
    },
    bar: {
      type: "integer",
    },
  },
} as const;

const root = {
  $ref: "https://example.local/types/#/definitions/foo",
} as const;

type Root = FromSchema<
  typeof root,
  {
    references: [typeof types];
  }
>;

Version 2.7.2 currently resolves Root to never, whereas I was expecting it to resolve to number.

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