This shows up while trying to convert the latest OpenAI specs.
Issue Type
input parsing
Context (Environment, Version, Language)
- Environment: macOS, Apple Silicon, Node.js v24.15.0
- Quicktype versions: 23.3.25 and 24.0.2
- Also reproduced on: upstream
master at commit 7a86b5e1042f7bc387876fbbb0c0547d2ca22cbc
- Input language: JSON Schema draft-07
- Output language: Rust
Description
I'm trying to parse OpenAI's OpenAPI spec and create generated types
Input Data
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"input": {
"type": "array",
"items": {
"oneOf": [
{ "$ref": "#/definitions/Message" },
{ "$ref": "#/definitions/Item" }
]
}
}
},
"definitions": {
"Message": {
"type": "object",
"properties": {
"content": { "type": "string" }
},
"required": ["content"]
},
"Item": {
"oneOf": [
{ "$ref": "#/definitions/FunctionOutput" },
{ "$ref": "#/definitions/ReasoningItem" }
]
},
"FunctionOutput": {
"allOf": [
{ "$ref": "#/definitions/BaseItem" },
{
"type": "object",
"properties": {
"output": { "type": "string" }
},
"required": ["output"]
}
]
},
"BaseItem": {
"type": "object",
"properties": {
"id": { "type": "string" }
},
"required": ["id"]
},
"ReasoningItem": {
"type": "object",
"properties": {
"summary": { "type": "string" }
},
"required": ["summary"]
}
}
}
Expected Behaviour / Output
Something like
#[derive(Serialize, Deserialize)]
pub struct TopLevel {
pub input: Option<Vec<Item>>,
}
#[derive(Serialize, Deserialize)]
pub struct Item {
pub content: Option<String>,
pub id: Option<String>,
pub output: Option<String>,
pub summary: Option<String>,
}
Current Behaviour / Output
Error: Internal error: Unknown type intersection.
Steps to Reproduce
Save the above json schema to nested-intersection.schema.json and then run
npx quicktype@24.0.2 \
--src-lang schema \
--lang rust \
nested-intersection.schema.json
Possible Solution
Will send a PR
This shows up while trying to convert the latest OpenAI specs.
Issue Type
input parsing
Context (Environment, Version, Language)
masterat commit7a86b5e1042f7bc387876fbbb0c0547d2ca22cbcDescription
I'm trying to parse OpenAI's OpenAPI spec and create generated types
Input Data
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "input": { "type": "array", "items": { "oneOf": [ { "$ref": "#/definitions/Message" }, { "$ref": "#/definitions/Item" } ] } } }, "definitions": { "Message": { "type": "object", "properties": { "content": { "type": "string" } }, "required": ["content"] }, "Item": { "oneOf": [ { "$ref": "#/definitions/FunctionOutput" }, { "$ref": "#/definitions/ReasoningItem" } ] }, "FunctionOutput": { "allOf": [ { "$ref": "#/definitions/BaseItem" }, { "type": "object", "properties": { "output": { "type": "string" } }, "required": ["output"] } ] }, "BaseItem": { "type": "object", "properties": { "id": { "type": "string" } }, "required": ["id"] }, "ReasoningItem": { "type": "object", "properties": { "summary": { "type": "string" } }, "required": ["summary"] } } }Expected Behaviour / Output
Something like
Current Behaviour / Output
Steps to Reproduce
Save the above json schema to
nested-intersection.schema.jsonand then runPossible Solution
Will send a PR