Skip to content

Commit

Permalink
add test case for bcherny#613
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherny committed Aug 12, 2024
1 parent 402e188 commit 7c6bad4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/__snapshots__/test/test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -448260,6 +448260,26 @@ Generated by [AVA](https://avajs.dev).
}␊
`

## ref.7.js

> Expected output to match snapshot for e2e test: ref.7.js

`/* eslint-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 Sample {␊
neighborhood?: Person[];␊
}␊
export interface Person {␊
age?: number;␊
[k: string]: unknown;␊
}␊
`

## refWithCycle.1.js

> Expected output to match snapshot for e2e test: refWithCycle.1.js
Expand Down
Binary file modified test/__snapshots__/test/test.ts.snap
Binary file not shown.
37 changes: 37 additions & 0 deletions test/e2e/ref.7.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// @see https://github.com/bcherny/json-schema-to-typescript/issues/613
export const input = {
$schema: 'https://json-schema.org/draft/2020-12/schema',
title: 'Sample',
type: 'object',
additionalProperties: false,
properties: {
neighborhood: {
type: 'array',
items: {
$ref: '#/$defs/person',
},
},
},
$defs: {
baseType: {
title: 'BaseType',
type: 'object',
properties: {
name: {
type: 'string',
},
},
},
person: {
title: 'Person',
$ref: '#/$defs/baseType',
type: 'object',
unevaluatedProperties: false,
properties: {
age: {
type: 'number',
},
},
},
},
}

0 comments on commit 7c6bad4

Please sign in to comment.