-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Issue Type
Quicktype output
Context (Environment, Version, Language)
Input Format: JSON schema
Output Language: Typescript
CLI, npm, or app.quicktype.io: npm
Version: 23.2.6
Description
The Tuple validation section of JSON schema describes how prefixItems should be used to validate against a array-based tuple schema. Unfortunately, npx quicktype --src-lang schema --lang typescript --just-types --src Foo.json appears to output nothing when passed such a schema.
Input Data
schemars cargo package generates these valid schemas when parsing tuple structs, for example:
#[derive Serialize, Deserialize, JsonSchema]
struct Foo(Bar, Baz)Yields:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "...",
"type": "array",
"prefixItems": [
{
"$ref": "#/$defs/Bar"
},
{
"$ref": "#/$defs/Baz"
}
],
"$defs": {
// ... inline definitions of Bar and Baz structs
}
"minItems": 2,
"maxItems": 2
}
Expected Behaviour / Output
I expected a interface type to be generated, as done when Bar and Baz refs are placed under items instead of prefixItems:
export interface Foo {
Bar?: Bar;
Faz?: Baz;
[property: string]: any;
}
Current Behaviour / Output
Nothing is generated
Steps to Reproduce
- Create a tuple-schema using prefixItems (e.g. see spec's doc samples)
- npx quicktype --src-lang schema --lang typescript --just-types --src thattype.json