acacode / acacode/swagger-typescript-api

Infer object type from additionalProperties when type is omitted

Đang mở
#1,822 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
4.1k
Fork
436
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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).

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.