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
When generating go code from schemas within a single package, different enums with the same named members will conflict with each-other. With a --enum-type-name-suffix flag (default false), we can instead append the enum type name to the end of the constant (which is a common approach to avoid these conflicts). See a worked example below 😁
a two line change (that I'll PR after submitting this issue)
Alternatives
Generating with different package names would "resolve" the conflicts, but does not work for our use case (we have many enums that conflict with each-other in this manner, and would rather not create a separate package for each).
The text was updated successfully, but these errors were encountered:
Context (Input, Language)
Input Format: schema
Output Language: go
Description
When generating go code from schemas within a single package, different enums with the same named members will conflict with each-other. With a
--enum-type-name-suffix
flag (defaultfalse
), we can instead append the enum type name to the end of the constant (which is a common approach to avoid these conflicts). See a worked example below 😁Current Behaviour / Output
Consider the following json schemas:
Currently, running the following two commands:
will generate the following files:
which will cause a
redeclared in this block
error.Proposed Behaviour / Output
When passing an additional flag
--enum-type-name-suffix
to thequicktype
command, generate:Solution
a two line change (that I'll PR after submitting this issue)
Alternatives
Generating with different package names would "resolve" the conflicts, but does not work for our use case (we have many enums that conflict with each-other in this manner, and would rather not create a separate package for each).
The text was updated successfully, but these errors were encountered: