Open MasatoYagi opened 2 years ago
Missing import when a model's property is an array/map of file https://swagger.io/specification/v2/#:~:text=Model%20with%20Map/Dictionary%20Properties
3.0.34, 3.0.34
https://gist.githubusercontent.com/Masato516/ae52739d1dfd79a37edabe7375319df6/raw/5cef0fb8fe3a9664b51646845e1aca295314c155/vuls-sample.yaml
swagger-codegen generate -i https://gist.githubusercontent.com/Masato516/ae52739d1dfd79a37edabe7375319df6/raw/5cef0fb8fe3a9664b51646845e1aca295314c155/vuls-sample.yaml -l go -o ~/project/swagger-codegen/go/out/
go run the below main.go (Due to a build error, the content of the code is not relevant to the problem.)
package main import ( "fmt" sw "localpackages/swagger" ) func main() { configuration := sw.NewConfiguration() apiClient := sw.NewAPIClient(configuration) fmt.Println(apiClient) }
output
Build Error: go build -o /Users/masato/project/swagger-codegen/go/example/api/__debug_bin -gcflags all=-N -l . # localpackages/swagger ../swagger/model_task_get_task_detail_response_body.go:26:19: undefined: os (exit status 2)
I reported a similar problem on the Openapi-generator that forked Swagger-codegen and got it fixed https://github.com/OpenAPITools/openapi-generator/pull/13143
The following PR from the openapi-generator may be helpful in solving the problem. https://github.com/OpenAPITools/openapi-generator/pull/13143
Ver 2.x doesn't cause the error.
Description
Missing import when a model's property is an array/map of file https://swagger.io/specification/v2/#:~:text=Model%20with%20Map/Dictionary%20Properties
Swagger-codegen version
3.0.34, 3.0.34
Swagger declaration file content or url
https://gist.githubusercontent.com/Masato516/ae52739d1dfd79a37edabe7375319df6/raw/5cef0fb8fe3a9664b51646845e1aca295314c155/vuls-sample.yaml
Command line used for generation
swagger-codegen generate -i https://gist.githubusercontent.com/Masato516/ae52739d1dfd79a37edabe7375319df6/raw/5cef0fb8fe3a9664b51646845e1aca295314c155/vuls-sample.yaml -l go -o ~/project/swagger-codegen/go/out/
Steps to reproduce
go run the below main.go (Due to a build error, the content of the code is not relevant to the problem.)
output
Related issues/PRs
I reported a similar problem on the Openapi-generator that forked Swagger-codegen and got it fixed https://github.com/OpenAPITools/openapi-generator/pull/13143
Suggest a fix/enhancement
The following PR from the openapi-generator may be helpful in solving the problem. https://github.com/OpenAPITools/openapi-generator/pull/13143