Skip to content

Commit

Permalink
Fix cycles during generating (fix #376, fix #323)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Cherny committed May 22, 2022
1 parent e65ad1f commit a364345
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/e2e/refWithCycle.5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const only = true

// Cycle in referenced schema
// @see https://github.com/bcherny/json-schema-to-typescript/issues/376
export const input = {
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
properties: {
owner: {$ref: 'test/resources/Person.json'}
}
}
11 changes: 11 additions & 0 deletions test/resources/MultiSchema/foo/bar/out/a.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* tslint:disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

export interface ASchema {
f: string;
g?: number;
}
12 changes: 12 additions & 0 deletions test/resources/MultiSchema/foo/bar/out/b.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* tslint:disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

export interface BSchema {
x?: string;
y: number;
[k: string]: unknown;
}
13 changes: 13 additions & 0 deletions test/resources/Person.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"type": "object",
"properties": {
"name": {
"type": "string"
},
"children": {
"$ref": "#"
}
}
}

1 comment on commit a364345

@AndyA
Copy link

@AndyA AndyA commented on a364345 May 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this fix anything? It seems to affect only tests.

Please sign in to comment.