Skip to content

Commit

Permalink
fix: relative links to top-level schema
Browse files Browse the repository at this point in the history
  • Loading branch information
elyukai committed Mar 16, 2022
1 parent c73960c commit ca7f49b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/renderers/jsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,14 @@ const nodeToDefinition = (node: ChildNode): Definition => {
}
}

const toForwardSlashPath = (path: string) => path.split(sep).join("/")
const toForwardSlashAbsolutePath = (path: string) => "/" + path.split(sep).join("/")

const astToJsonSchema: AstTransformer = (file, { relativePath }): string => {
const mainType = file.jsDoc?.tags.main

const jsonSchema = {
$schema: "http://json-schema.org/draft-07/schema",
$id: toForwardSlashPath(relativePath),
$id: toForwardSlashAbsolutePath(relativePath),
$ref: mainType ? `#/definitions/${mainType}` : mainType,
definitions: Object.fromEntries(
Object.entries(file.elements)
Expand Down

0 comments on commit ca7f49b

Please sign in to comment.