Skip to content

Support additionalProperties: true #1154

Open
@ajenkins-cargometrics

Description

@ajenkins-cargometrics

In OpenAPI 3, a schema like:

    AnyValues:
      description: An object whose property values can be of any type
      type: object
      additionalProperties: true

Should be equivalent to a typescript type like:

type AnyValues = {
    [key: string]: any
};

However what openapi-typescript-codegen actually generates is a type like this:

type AnyValues = {
};

That is, an object with no properties.

Additionally, OpenAPI allows combining additionalProperties: true with explicit property definitions. So an OpenAPI schema like this:

SomeType:
    type: object
    required: [name]
    properties:
        name:
            type: string
    additionalProperties: true

Should result in a typescript type like:

type SomeType = {
    name: string,
    [key: string]: any
};

but in fact it results in:

type SomeType = {
    name: string
};

Desired result: additionalProperties: true in an object schema should result in a [key: string]: any property in the corresponding typescript type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions