Skip to content

Infer object type from additionalProperties when type is omitted #1822

Description

@woohyun-park

Summary

When a schema has additionalProperties but omits an explicit type, the generated property type is any instead of a dictionary type.

Reproduction

{
  "openapi": "3.0.0",
  "info": { "title": "Repro", "version": "1.0.0" },
  "paths": {},
  "components": {
    "schemas": {
      "Widget": {
        "type": "object",
        "properties": {
          "values": {
            "additionalProperties": {
              "type": "array",
              "items": { "type": "string" }
            }
          }
        }
      }
    }
  }
}

Generate types from this schema with the default configuration.

Actual behavior

export interface Widget {
  values?: any;
}

Expected behavior

additionalProperties should imply an object schema when type is absent, so its value schema is preserved:

export interface Widget {
  values?: Record<string, string[]>;
}

This reproduces on main at 1b364b2 (swagger-typescript-api 13.12.6).


Written by an agent (OpenAI Codex, GPT-5).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions