[BUG]: Missing additionalProperties mapping
Quicktype does not generate a field for additionalProperties in the output Go struct
Issue Type
Quicktype output
Context (Environment, Version, Language)
Input Format: JSON Schema Output Language: Go
CLI, npm, or app.quicktype.io: CLI Version: 23.0.171
Description
The devcontainer base schema uses additionalProperties for defining a set of devcontainer features. Without a field to read the map of additional properties it's not possible to implement the features spec without modifying the generated Go code or the original schema JSON.
Input Data
test.schema.json:
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"properties": {
"deprecatedField": {
"deprecated": true
}
},
"additionalProperties": true
}
Expected Behaviour / Output
The generated struct contains fields for the deprecated field, plus some field for accessing additionalProperties, e.g:
type TestSchema struct {
DeprecatedField interface{} `json:"deprecatedField"`
AdditionalProperties map[string]interface{}
}
Current Behaviour / Output
Only the deprecated field is generated:
type TestSchema struct {
DeprecatedField interface{} `json:"deprecatedField"`
}
Steps to Reproduce
run with the schema input above:
quicktype --lang go --src-lang schema --src ./test.schema.json
I have also faced this issue while trying to generate models for MCP (https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json#L1657)
I had to modify the generated classes manually. I think this is a huge blocker and it makes the tool much less useful, as if you need to modify the generated code, you don't really get the benefit of auto-generation. I bet AI can generate better code at this point 🙂
Let me know if you have any suggestions and workarounds. I am looking for answers that would enable me to use auto-generated stubs directly. I also accept other library recommendations?