Skip to content

[BUG]: Missing additionalProperties mapping #2684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dmipeck opened this issue Feb 8, 2025 · 1 comment
Open

[BUG]: Missing additionalProperties mapping #2684

dmipeck opened this issue Feb 8, 2025 · 1 comment
Labels

Comments

@dmipeck
Copy link

dmipeck commented Feb 8, 2025

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 dmipeck added the bug label Feb 8, 2025
@Dogacel
Copy link

Dogacel commented Apr 2, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants