Skip to content

Commit

Permalink
Gen types.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed May 19, 2024
1 parent 5ec1561 commit 4755b95
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/schematic/tests/macros_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ fn generates_json_schema() {
generator.add::<NestedValidations>();
generator.add::<Validations>();
generator.add::<Comments>();
generator.add::<UnnamedSingle>();
generator.add::<UnnamedMultiple>();
generator.add::<UnnamedNested>();
generator.add::<UnnamedCollection>();
// Partials are separate
generator.add::<PartialDefaultValues>();
generator.add::<PartialNested>();
Expand Down Expand Up @@ -357,6 +361,10 @@ fn generates_typescript() {
generator.add::<NestedValidations>();
generator.add::<Validations>();
generator.add::<Comments>();
generator.add::<UnnamedSingle>();
generator.add::<UnnamedMultiple>();
generator.add::<UnnamedNested>();
generator.add::<UnnamedCollection>();
// Partials are separate
generator.add::<PartialDefaultValues>();
generator.add::<PartialNested>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,30 @@ expression: "std::fs::read_to_string(file).unwrap()"
"b-a-z"
]
},
"UnnamedMultiple": {
"title": "UnnamedMultiple",
"type": "array",
"items": [
{
"type": "string"
},
{
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
]
},
{
"type": "boolean"
}
],
"maxItems": 3,
"minItems": 3
},
"Validations": {
"title": "Validations",
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export type Comments = {
normal: boolean,
};

export type UnnamedMultiple = [string, number | null, boolean];

export type PartialDefaultValues = {
array?: number[] | null,
arrayOpt?: number[] | null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export interface Comments {
normal: boolean;
}

export type UnnamedMultiple = [string, number | null, boolean];

export interface PartialDefaultValues {
array?: number[] | null;
arrayOpt?: number[] | null;
Expand Down

0 comments on commit 4755b95

Please sign in to comment.