acacode / acacode/swagger-typescript-api

Infer object type from additionalProperties when type is omitted

未关闭
#1,822 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
4.1k
派生
436
PR 合并指标
30 天内没有已合并 PR

描述

### Summary

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

### Reproduction

```json
{
"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

```ts
export interface Widget {
values?: any;
}
```

### Expected behavior

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

```ts
export interface Widget {
values?: Record;
}
```

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

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

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。