Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports untagged enum #89

Open
iboss-ptk opened this issue Dec 7, 2022 · 5 comments
Open

Supports untagged enum #89

iboss-ptk opened this issue Dec 7, 2022 · 5 comments

Comments

@iboss-ptk
Copy link

iboss-ptk commented Dec 7, 2022

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

#[cw_serde]
#[serde(untagged)]
pub enum ExecuteMsg {
    CW721Base(cw721_base::ExecuteMsg<cw721_base::Extension, Empty>),
    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

@pyramation
Copy link
Collaborator

hey @iboss-ptk can you send me a full schema I can use for testing?

@pyramation
Copy link
Collaborator

Also, what is the expectation of ExecuteMsg_for_Nullable_Empty_and_Empty, I know it may be unrelated, but perhaps ExecuteMsgForNullableEmptyAndEmpty?

@iboss-ptk
Copy link
Author

It's from ExecuteMsg<Option<Empty>,Empty>, I'm remapping it with name and it works fine now. Not sure of a good representation in ts, your suggestion should just work as well.

@iboss-ptk
Copy link
Author

will sent you the schema for testing

@pyramation
Copy link
Collaborator

cool, lmk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants