Bug Report Checklist
Description
The generated go-experimental code has multiple issues that cause syntax errors:
- Use but does not define the "NullableMap" type
- Refer to the "NullableTime.Time" type, but the type is actually "NullableTime"
- Import but does not use the "time" package
- Refer to the Nullable[]map[string]interface{}, which is not a valid golang type.
- Some "const" values are defined twice with the same identifier, once for the enum value, and once for the default value.
Other issues found:
- Missing pom.xml files in the go and go-experimental directories.
This can be easily reproduced in the openapi3 petstore sample. Specifically, the petstore sample petstore-with-fake-endpoints-models-for-testing.yaml is used to generate go-experimental code, but that code does not compile.
As an example, the go-experimental generator generates the following code:
/ NullableClass struct for NullableClass
type NullableClass struct {
....
ArrayNullableProp *Nullable[]map[string]interface{} `json:"array_nullable_prop,omitempty"`
...
}
"*Nullable[]map[string]interface{}" is not a valid go type.
This code is committed in git at https://github.com/OpenAPITools/openapi-generator/blob/master/samples/openapi3/client/petstore/go-experimental/go-petstore/model_nullable_class.go#L26
A secondary problem is that the CircleCI build does not catch the go compilation error (because of missing shell script in bin/utils/ensure-up-to-date).
openapi-generator version
master January 21 2020
OpenAPI declaration file content or url
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
Command line used for generation
mvn package
./bin/openapi3/go-experimental-petstore.sh
Steps to reproduce
In the commands below, I used go 1.12.9, but the same problem would occur with any version.
./bin/openapi3/go-experimental-petstore.sh
cp -R samples/openapi3/client/petstore/go-experimental/* ~/tmp/
cd /tmp
go test -v ./...
The go compiler raises the following errors:
go-petstore/model_nullable_class.go:26:29: syntax error: unexpected [, expecting semicolon or newline or }
go-petstore/model_nullable_class.go:233:56: syntax error: unexpected [ after top level declaration
...
go-petstore/model_nullable_class.go:276:58: too many errors
Expected output:
The go code should compile without error.
Also:
go-petstore/model_outer_enum_default_value.go:22:2: PLACED redeclared in this block
previous declaration at go-petstore/model_outer_enum.go:22:21
Related issues/PRs
Suggest a fix
The problem is because of an issue in the following postProcessModels() method:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java#L90
Bug Report Checklist
Description
The generated go-experimental code has multiple issues that cause syntax errors:
Other issues found:
This can be easily reproduced in the openapi3 petstore sample. Specifically, the petstore sample petstore-with-fake-endpoints-models-for-testing.yaml is used to generate go-experimental code, but that code does not compile.
As an example, the go-experimental generator generates the following code:
"*Nullable[]map[string]interface{}" is not a valid go type.
This code is committed in git at https://github.com/OpenAPITools/openapi-generator/blob/master/samples/openapi3/client/petstore/go-experimental/go-petstore/model_nullable_class.go#L26
A secondary problem is that the CircleCI build does not catch the go compilation error (because of missing shell script in bin/utils/ensure-up-to-date).
openapi-generator version
master January 21 2020
OpenAPI declaration file content or url
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
Command line used for generation
Steps to reproduce
In the commands below, I used go 1.12.9, but the same problem would occur with any version.
The go compiler raises the following errors:
Expected output:
The go code should compile without error.
Also:
Related issues/PRs
Suggest a fix
The problem is because of an issue in the following postProcessModels() method:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java#L90