Skip to content
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

AdditionalProperties ignored for Typescript definition generation #1615

Closed
fredericbarthelet opened this issue Dec 20, 2020 · 1 comment · Fixed by #2029
Closed

AdditionalProperties ignored for Typescript definition generation #1615

fredericbarthelet opened this issue Dec 20, 2020 · 1 comment · Fixed by #2029

Comments

@fredericbarthelet
Copy link

Thanks for the amazing work done in this library !
I'm struggling a bit with additionalProperties JSON-schema property.
As stated from the documentation:

The additionalProperties keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the properties keyword. By default any additional properties are allowed.

So, not defining additionalProperties is equivalent to "additionalProperties": true

However, given the following JSON-schema

{
    "type": "object",
    "properties": {
        "a": { "type": "string" }
    },
    "required": ["a"]
}

the generated Typescript definition is

export interface MyObject {
    a: string;
}

while I was expecting

export interface MyObject {
    a: string;
    [key: string]: unknown;
}

I tried setting "additionalProperties": true and even "additionalProperties": { type: "string" }, without any success. It looks like additionalProperties does not have any impact on generated Typescript definition.
You can access my latest test at https://app.quicktype.io?share=Y4Y07xZGS9zncuWpEtSt

Any advice on how to proceed with this issue ? Happy to help with a PR if pointed in the right direction :)

@nickfryar
Copy link

Any update on this? I'm having the same issue 10 months later. Also glad to help with a PR!

dvdsgl pushed a commit that referenced this issue Dec 30, 2022
* AdditionalProperties ignored for Typescript definition generation #1615
 #1615

* AdditionalProperties ignored for Typescript definition generation #1615
 #1615

* AdditionalProperties ignored for Typescript definition generation #1615
 #1615

* AdditionalProperties ignored for Typescript definition generation #1615
 #1615

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

Successfully merging a pull request may close this issue.

2 participants