openmicroservices.org
openmicroservices.org copied to clipboard
Should we use `enum` as a basic type key word?
From OpenAPI Specification, define enum like below:
type: string
enum:
- a
- b
We declare the type of enum's item.
Should OMG change to that style?
While there's the infamous YAML variable reference trick (e.g. https://github.com/microservices/microservice.guide/issues/85), it doesn't help as there's still no way to specify the underlying type. So yeah I think this would be a pretty useful change :+1: Range even works the same today as well:
type: int
range: # default is no bounds for min and max
min: 10
max: 20
(from: https://microservice.guide/schema/actions/#arguments)
There's of course the question what should happen when the user defines sth. like:
type: int
enum:
- a
- b
But imho it would be reasonable to only allow a few common mappings (e.g. no float) and in the case above start with 0.
A bit off-topic:
It should be possible to specify such enums on the top level. This can be combined with objects (https://github.com/microservices/microservice.guide/issues/60) to a custom types section as proposed in https://github.com/microservices/microservice.guide/issues/50 with nested "structs" and objects.
@wilzbach Please give this comment a thumbs up if we consider this resolved.
@matthewhudson: no it's not resolved. The user is asking for enum to behave like range (i.e. allowing a custom type).