-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enum support for golang in swagger-codegen #4459
Comments
I checked with petstore as well, It is not generating the enum inside pet object. |
@jeetcontext @wing328 I am interested in working on this issue. go-swagger is providing |
Go does not support enum, so i think it is as simple as validating input is one of the enum elements as @jeetcontext suggest. But, to throw a wrench in the gears a bit...
We know Go also does not allow nil data types, so this may be better using interface{} or pointers. |
@wing328 I intended not to add |
Just ran into this. FWIW Go "enums" are typically done like this: type MyEnum string
const (
Foo MyEnum = "foo"
Bar MyEnum = "bar"
) |
@vpolouchkine thanks for sharing. Has anyone started working on this yet? If yes, please kindly share the progress. Thanks. |
I wouldn't mind helping out with this. It seems trivial to generate enums in golang (basically a type alias). But as I'm new to swagger-codegen, could someone please let me know where I can read the logic of the swagger-spec java parser? Specifically, I'm not sure what fields are in the hash used with the mustache templates. |
Description
I am trying to generate sdk for golang with respect to a json file. It is not able to generate the enum type.
Swagger-codegen version
Version 2.2.2-snapshot
Swagger declaration file content or url
"catalog_type": {
"description": "Type of the catalog",
"enum": [
"CATALOG_A",
"CATALOG_B"
],
"title": "Catalog type",
"type": "string"
}
This is part of json file.
Command line used for generation
After doing the mvn build, used
Java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i test.json -o ./gosdk
Steps to reproduce
Related issues
There is another dev going on with go-swagger which supports enum.
Suggest a Fix
May be the template file and the GoClientCodegen file needs to be updated for complex json.
The text was updated successfully, but these errors were encountered: