-
Notifications
You must be signed in to change notification settings - Fork 222
add support for a types array #2410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f40b65d
add for multiple-types, test failing
srsudar fcc6e38
passes with all types listed
srsudar a5171a1
fix tests
srsudar f8ac2d4
update comment
srsudar 72164e6
switch to only array
srsudar 7020a1e
a few switcheroos
srsudar a7a8208
throw on type/types
srsudar 8c3ff40
fix tests
srsudar 4bf3f07
code review
srsudar 58dbdf1
code review
srsudar 11dfab5
Apply suggestion from @domoritz
domoritz a8d159b
doc update
srsudar 7aa46a5
Merge branch 'sam-multiple-types' of github.com:srsudar/ts-json-schem…
srsudar 974c8a6
add a test for mixing types
srsudar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
| type NonExportedType = { | ||
| misc: number; | ||
| }; | ||
|
|
||
| export type ExportedType = { | ||
| val: string; | ||
| val2: NonExportedType; | ||
| }; | ||
|
|
||
| export interface ExportedInterface { | ||
| val: string; | ||
| } | ||
|
|
||
| export type Object1Prop = { | ||
| name: string; | ||
| }; | ||
|
|
||
| export type Object2Prop = { | ||
| description: string; | ||
| }; | ||
|
|
||
| export type MyObject1 = { | ||
| id: number; | ||
| bar: Object1Prop; | ||
| }; | ||
|
|
||
| export type MyObject2 = { | ||
| idStr: string; | ||
| baz: Object2Prop; | ||
| }; |
This file contains hidden or 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,61 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "definitions": { | ||
| "MyObject1": { | ||
| "properties": { | ||
| "id": { | ||
| "type": "number" | ||
| }, | ||
| "bar": { | ||
| "$ref": "#/definitions/Object1Prop" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "id", | ||
| "bar" | ||
| ], | ||
| "type": "object", | ||
| "additionalProperties": false | ||
| }, | ||
| "MyObject2": { | ||
| "properties": { | ||
| "idStr": { | ||
| "type": "string" | ||
| }, | ||
| "baz": { | ||
| "$ref": "#/definitions/Object2Prop" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "idStr", | ||
| "baz" | ||
| ], | ||
| "type": "object", | ||
| "additionalProperties": false | ||
| }, | ||
| "Object1Prop": { | ||
| "properties": { | ||
| "name": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "name" | ||
| ], | ||
| "type": "object", | ||
| "additionalProperties": false | ||
| }, | ||
| "Object2Prop": { | ||
| "properties": { | ||
| "description": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "description" | ||
| ], | ||
| "type": "object", | ||
| "additionalProperties": false | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,31 @@ | ||
| type NonExportedType = { | ||
| misc: number; | ||
| }; | ||
|
|
||
| export type ExportedType = { | ||
| val: string; | ||
| val2: NonExportedType; | ||
| }; | ||
|
|
||
| export interface ExportedInterface { | ||
| val: string; | ||
| } | ||
|
|
||
| // Exported, so we include it as a root node | ||
| export type Object1Prop = { | ||
| name: string; | ||
| }; | ||
|
|
||
| type Object2Prop = { | ||
| description: string; | ||
| }; | ||
|
|
||
| export type MyObject1 = { | ||
| id: number; | ||
| bar: Object1Prop; | ||
| }; | ||
|
|
||
| export type MyObject2 = { | ||
| idStr: string; | ||
| baz: Object2Prop; | ||
| }; |
This file contains hidden or 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,58 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "definitions": { | ||
| "MyObject1": { | ||
| "properties": { | ||
| "id": { | ||
| "type": "number" | ||
| }, | ||
| "bar": { | ||
| "$ref": "#/definitions/Object1Prop" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "id", | ||
| "bar" | ||
| ], | ||
| "type": "object", | ||
| "additionalProperties": false | ||
| }, | ||
| "MyObject2": { | ||
| "properties": { | ||
| "idStr": { | ||
| "type": "string" | ||
| }, | ||
| "baz": { | ||
| "properties": { | ||
| "description": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "description" | ||
| ], | ||
| "type": "object", | ||
| "additionalProperties": false | ||
| } | ||
| }, | ||
| "required": [ | ||
| "idStr", | ||
| "baz" | ||
| ], | ||
| "type": "object", | ||
| "additionalProperties": false | ||
| }, | ||
| "Object1Prop": { | ||
| "properties": { | ||
| "name": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "name" | ||
| ], | ||
| "type": "object", | ||
| "additionalProperties": false | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.