-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
012057c
commit ea19b59
Showing
8 changed files
with
156 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface Memo { | ||
schema?: string; | ||
memoKeys: { | ||
key: string; | ||
description: string; | ||
gitRepo: string; | ||
memo: any; | ||
}[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface Memo { | ||
$schema?: string; | ||
memo_keys: { | ||
key: string; | ||
description: string; | ||
git_repo: string; | ||
memo: any; | ||
}[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`additional 1`] = ` | ||
"export interface Person { | ||
firstName: string; | ||
lastName: string; | ||
age?: number; | ||
[key: string]: string; | ||
}" | ||
`; | ||
|
||
exports[`additional 2`] = ` | ||
"export interface Person { | ||
firstName: string; | ||
[key: string]: { | ||
newProp: any; | ||
}; | ||
}" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`memo 1`] = ` | ||
"export interface Memo { | ||
$schema?: string; | ||
memo_keys: { | ||
key: string; | ||
description: string; | ||
git_repo: string; | ||
memo: any; | ||
}[]; | ||
}" | ||
`; | ||
|
||
exports[`memo camelCase 1`] = ` | ||
"export interface Memo { | ||
schema?: string; | ||
memoKeys: { | ||
key: string; | ||
description: string; | ||
gitRepo: string; | ||
memo: any; | ||
}[]; | ||
}" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { generateTypeScript } from '../src'; | ||
|
||
it('additional', () => { | ||
expect(generateTypeScript({ | ||
"$id": "https://example.com/person.schema.json", | ||
"$schema": "https://json-schema.org/draft-07/schema#", | ||
"title": "Person", | ||
"type": "object", | ||
"properties": { | ||
"firstName": { | ||
"type": "string" | ||
}, | ||
"lastName": { | ||
"type": "string" | ||
}, | ||
"age": { | ||
"type": "integer" | ||
} | ||
}, | ||
"required": ["firstName", "lastName"], | ||
"additionalProperties": true | ||
} as any)).toMatchSnapshot() | ||
}) | ||
|
||
it('additional', () => { | ||
expect(generateTypeScript({ | ||
"title": "Person", | ||
"type": "object", | ||
"properties": { | ||
"firstName": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["firstName"], | ||
"additionalProperties": { | ||
"title": "Car", | ||
"type": "object", | ||
"properties": { | ||
"newProp": { | ||
"type": "Person" | ||
} | ||
}, | ||
"required": ["newProp"], | ||
"additionalProperties": true | ||
} | ||
} as any)).toMatchSnapshot() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { writeFileSync } from 'fs'; | ||
|
||
import schema from '../__fixtures__/schemas/memo.json'; | ||
import { generateTypeScript } from '../src'; | ||
|
||
it('memo', () => { | ||
const code = generateTypeScript(schema as any); | ||
expect(code).toMatchSnapshot(); | ||
writeFileSync(__dirname + '/../__fixtures__/output/memo.ts', code); | ||
}); | ||
|
||
it('memo camelCase', () => { | ||
const code = generateTypeScript(schema as any, { | ||
useSingleQuotes: true, | ||
useCamelCase: true | ||
}); | ||
expect(code).toMatchSnapshot(); | ||
writeFileSync(__dirname + '/../__fixtures__/output/memo.camel.ts', code); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters