hyperweb-io / hyperweb-io/ts-codegen

Supports untagged enum

Đang mở
#89 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
126
Fork
31
Merge trung bình
19 phút
Pull request đã merge (30 ngày)
2

Mô tả

Current ts-codegen can't generate code from the following schema

```
{
...
"execute": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ExecuteMsg",
"anyOf": [
{
"$ref": "#/definitions/ExecuteMsg_for_Nullable_Empty_and_Empty"
},
{
"$ref": "#/definitions/ICNSNameExecuteMsg"
}
],
"definitions": { ... },
...
}
```

as it tries to find properties under value of "execute" but it couldn't find one.

This schema is generated from

```rs
#[cw_serde]
#[serde(untagged)]
pub enum ExecuteMsg {
CW721Base(cw721_base::ExecuteMsg),
ICNSName(ICNSNameExecuteMsg),
}
```

It fails as it tries to find `Object.keys` on execute's `properties` but it couldn't find one on [this line of code](https://github.com/CosmWasm/ts-codegen/blob/cffa2acebb86f3c1f96fb00c4abae5ba0987e63e/packages/wasm-ast-types/src/client/client.ts#L266)

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

Hướng nghiên cứu

The failure is in packages/wasm-ast-types/src/client/client.ts at line 266, where the generated schema's execute value lacks properties. Start by tracing how that code handles anyOf and the referenced definitions in the supplied draft-07 schema. Done means ts-codegen can generate code for the shown serde(untagged) ExecuteMsg without attempting Object.keys on missing properties.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
rust, typescript
Lĩnh vực
tooling
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

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.