acacode / acacode/swagger-typescript-api

Option for handle object without $ref (nested objects)

Đang mở
#639 1 bình luận 2 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ả

When generating the client, we pass the swagger. A swagger can include complex objects. Such objects usually have nested objects. So, if we want to access this nested object from code, then we can only get it if it is described inside the swagger using "$ref".
Example object in schema (without $ref)
```json
"work_day": {
"type": "object",
"description": "Workday state",
"properties": {
"uuid": {
"type": "string",
"description": "Workday uuid",
"example": "6e8242b9-adea-4d0a-ba74-07dc2cf6f459"
}
}
}
```

We generate some schema and result is:

```typescript
export interface Generated {
name?: string;
work_day?: {
uuid?: string;
};
}
```

But now, let use $ref inside our schema

```json
"work_day": {
"schema": {
"$ref": "#/components/schemas/Workday"
}
}
```

Result in TypeScript:

```typescript

export interface Generated {
name?: string;
work_day?: GeneratedWorkDay;
}

export interface GeneratedWorkDay {
uuid?: string;
}
```

It is possible to handle object without $ref?

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.