Replies: 1 comment
-
These two approaches are both valid depending on your cases. An approach that I've been using too is defining the enum type explicitly: var SortOrder = Type("SortOrder", String, func() {
Enum(types.NameAsc, types.NameDesc, types.CreatedAsc, types.CreatedDesc)
}) where |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I have multiple payloads that I am designing to share the same standard pagination schema, and I assumed it would be best to reuse a common definition of the
Enum
, rather than duplicate them inline in each payload. SinceEnum
is a validation, not a type, it's not immediately obvious to me how to do this best.I've come up with the following ideas:
Define as a slice of
any
values:or, as a type "Sortable" that I can leverage via
Extend()
in my payload:The latter has the advantage that I can group multiple parameters related to pagination. The OpenAPI spec creates an extra object for the latter, but is otherwise unchanged with respect to the HTTP payload schema.
Any best practices or recommendations from others on reusing a set of Enum allowed values?
Beta Was this translation helpful? Give feedback.
All reactions