Open aSapien opened 5 years ago
The root of the error message is the key here:
cannot unmarshal bool into Go struct field .enum of type string
This points to a field named "enum" that has a boolean value instead of an expected string. It appears that the kind folks of Slack decided they needed to declare additional enum values/constants that reattempt to define their own custom "true" and "false" constants as booleans.
"defs_ok_false": {
"enum": [
false
],
"title": "default failure response",
"type": "boolean"
},
"defs_ok_true": {
"enum": [
true
],
"title": "default success response",
"type": "boolean"
},
This is kinda nutty IMO but it appears to match the OpenAPI 2.0 spec that an enum can be of "any" type.
Right now, openapi2proto
expects enums to have strings as values, which is causing the error. I hope you don't mind, but I'll rename this issue to better describe the problem at hand.
Thanks @jprobinson! Indeed it looks like their API is a mess. I've been trying to generate Slack's entities for quite some time. Unfortunately, openapi-generator also fails to generate data classes
I really hope somebody there is listening and the issue will be addressed
Reproduction steps:
curl -O https://api.slack.com/specs/openapi/v2/slack_web.json
openapi2proto -spec ./slack_web.json
error: failed to transpile: failed to load OpenAPI spec: failed to decode content: failed to unmarshal JSON: json: cannot unmarshal bool into Go struct field .enum of type string
Unfortunately I have little to no experience with Golang, so I'm pretty much clueless :/
Appreciate any help here