-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #477 from streamich/jtd
JTD support in `json-type`
- Loading branch information
Showing
7 changed files
with
140 additions
and
0 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,70 @@ | ||
// prettier-ignore | ||
export type JtdForm = | ||
| JtdEmptyForm | ||
| JtdRefForm | ||
| JtdTypeForm | ||
| JtdEnumForm | ||
| JtdElementsForm | ||
| JtdPropertiesForm | ||
| JtdValuesForm | ||
| JtdDiscriminatorForm | ||
; | ||
|
||
export interface JtdFormBase { | ||
metadata?: Record<string, unknown>; | ||
} | ||
|
||
export interface JtdEmptyForm extends JtdFormBase { | ||
nullable?: boolean; | ||
} | ||
|
||
export interface JtdRefForm extends JtdFormBase { | ||
ref: string; | ||
} | ||
|
||
export interface JtdTypeForm extends JtdFormBase { | ||
type: JtdType; | ||
} | ||
|
||
// prettier-ignore | ||
export type JtdType = | ||
| 'boolean' | ||
| 'float32' | ||
| 'float64' | ||
| 'int8' | ||
| 'uint8' | ||
| 'int16' | ||
| 'uint16' | ||
| 'int32' | ||
| 'uint32' | ||
| 'string' | ||
| 'timestamp' | ||
; | ||
|
||
export interface JtdEnumForm extends JtdFormBase { | ||
enum: string[]; | ||
} | ||
|
||
export interface JtdElementsForm extends JtdFormBase { | ||
elements: JtdForm[]; | ||
} | ||
|
||
export interface JtdPropertiesForm extends JtdFormBase { | ||
properties?: Record<string, JtdForm>; | ||
optionalProperties?: Record<string, JtdForm>; | ||
additionalProperties?: boolean; | ||
} | ||
|
||
export interface JtdValuesForm extends JtdFormBase { | ||
values: JtdForm; | ||
} | ||
|
||
export interface JtdDiscriminatorForm extends JtdFormBase { | ||
discriminator: string; | ||
mapping: Record<string, JtdForm>; | ||
} | ||
|
||
export interface JtdError { | ||
instancePath: string; | ||
schemaPath: string; | ||
} |
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
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
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