quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

[BUG]: Missing additionalProperties mapping

Open dmipeck opened this issue 8 months ago • 1 comments

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

dmipeck avatar Feb 08 '25 20:02 dmipeck