You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this code, we're using the serde tag #[serde(tag="type")] to transform the representation of our enum into an internally tagged format, as described in the serde documentation. This results in a generated JSON schema with an enum Type that can take string or number as a value.
I've created a branch on a fork that includes a fix for merging multiple enums with the same name in the definition registry. This situation arises here because the possible values of the Type enum are defined in each definition of the Value enum. You can find the fix in this commit: d210cad.
Struct enum with same attribute name
Another issue arises because each enumeration struct variant contains a value property with a different type. When generating code with go-codegen, this leads to the following error:
The issue arises due to a conflict in the type registration of Value_Value in the definition registry. Initially, Value_Value was registered as a string type. However, an attempt to register it again as an integer type has led to this problem.
For a more comprehensive understanding of the issue, you can refer to the original JSON schema that triggered this problem. It is available here. The corresponding representation in the Rust contract can be found here.
The text was updated successfully, but these errors were encountered:
Following a comment on my last PR (#98), I've encountered an issue when generating schema types from our smart contract JSON schema.
To illustrate the problem, consider the following Rust code snippet:
**Whole JSON Schema for example**
Internally tagged enum
In this code, we're using the serde tag
#[serde(tag="type")]
to transform the representation of our enum into an internally tagged format, as described in the serde documentation. This results in a generated JSON schema with an enumType
that can takestring
ornumber
as a value.Here's a snippet of the generated JSON schema:
I've created a branch on a fork that includes a fix for merging multiple enums with the same name in the definition registry. This situation arises here because the possible values of the
Type
enum are defined in each definition of theValue
enum. You can find the fix in this commit: d210cad.Struct enum with same attribute name
Another issue arises because each enumeration struct variant contains a
value
property with a different type. When generating code withgo-codegen
, this leads to the following error:The issue arises due to a conflict in the type registration of
Value_Value
in the definition registry. Initially,Value_Value
was registered as a string type. However, an attempt to register it again as an integer type has led to this problem.For a more comprehensive understanding of the issue, you can refer to the original JSON schema that triggered this problem. It is available here. The corresponding representation in the Rust contract can be found here.
The text was updated successfully, but these errors were encountered: