Defining Constants for Schemas / Open Enum #2740
Replies: 2 comments 1 reply
-
#1552 has some suggestions for extensible enums |
Beta Was this translation helpful? Give feedback.
1 reply
-
As noted, this is being tracked with more info at #1552, so I'm going to close this discussion. |
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
-
Hey everyone 👋
I was wondering if anyone ever faced a similar challenge like I am currently, and was able to solve it in a good way also supported by the tooling.
Assume an API which accepts web hooks. You have one endpoint with a schema where one property defines the type of event that happened. This event is a string.
Now here comes the tricky aspects: not all
eventId
values are treated the same way. The API understands some special values, while others might be accepted but not treated in any special way. I want to be able to document in a good way some known values for this property like an enum, but not limit the property to this values. In best case these defined values, are also generated then as constants by the code generator so that the client implementing the API might have these special values available instead of duplicating it manually:An output could look like this:
I thought of using
examples
for this case but would also need to extend the code generators for this purpose and it is not really a standard practice.Different explanation:
Has anybody ever tried to represent "open enums" in Open API Specification? I want to define properties which have predefined enum values, but are not limited to these. Some example use cases:
#FF0000
Code generators would behave like:
Beta Was this translation helpful? Give feedback.
All reactions