How to declare enums suitable for json-schema (as string type) and protobuf emitters #8033
Unanswered
icmtolentino
asked this question in
Json Schema
Replies: 0 comments
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.
-
I would like to define an enumeration that would be emitted to both json-schema and protobuf. It is required that the json schema treats the enums as a string type. However, the proto emitter requires the enumeration to be declared with numerical values.
example:
enum planetsEnumType{
mercury : 0,
venus : 1,
earth : 2
}
model planets{
name : planetsEnumType;
}
/** PROTO output: */
enum planetEnumType {
"mercury" = 0;
"venus" = 1;
"earth" = 2;
}
message planets {
planetEnumType name = 1;
}
/** JSON output: */
$id: planet.yaml
type: object
properties:
name:
$ref: planetEnumType.yaml
$id: planetEnumType.yaml
type: number
enum:
- 0
- 1
- 2
How can I make the json schema output treat the enum as string type?
Is there another way of defining numeric enum values for protobuf?
Beta Was this translation helpful? Give feedback.
All reactions