-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Problem statement
swagger generate server -A go-planting -f swagger.yml
fails on Transformed Spec. After a preliminary review of the spec, it is not seen why the resulting go
code has cycles in them.
Swagger specification
2.0
Steps to reproduce
First some background. I am porting an old clojure
application over to golang
. I took the swagger.json from that service and then did the following to transform it to an OpenAPI v2.0 specification. the swagger.json
was tranformed to YAML using
the following online tool. Further processing was required because the swagger.io
tool produced an OpenAPI v3.0 spec. To convert the OpenAPI v3.0 spec to a OpenAPI v2.0 (swagger) spec, an account was created at APIMATIC and the spec was "transformed" using the Transform API
button.
After the OpenAPI v2.0 (swagger) spec was generated and validated. The following command was run:
swagger generate server -A go-planting -f swagger.yml
Subsequently, the following commands were run to build the server:
go mod tidy && \
cd cmd/go-planting-server && \
go build
This resulted in a build error. Somehow the spec or swagger generates go
code with cycles in them. The errors are as follows:
package git.tcc.li/climate/pipelines/reg/go-planting/cmd/go-planting-server
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi/operations
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi/operations/core
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi/operations/v1
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi/operations/v1: import cycle not allowed
package git.tcc.li/climate/pipelines/reg/go-planting/cmd/go-planting-server
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi/operations
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi/operations/core
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi/operations/v1
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi/operations/v3
imports git.tcc.li/climate/pipelines/reg/go-planting/restapi/operations/v3: import cycle not allowed
Environment
swagger version: 0.30.3
go version: 1.18.3
OS: macOS Monterey Version 12.6