From 29df3bdb117a058ae040686dd0f2565ae9ad743a Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 14 Oct 2016 16:20:13 -0400 Subject: [PATCH] Use a config to generate swagger api types Moves the resposne types to a package under api/types Signed-off-by: Daniel Nephin --- api/server/router/volume/volume_routes.go | 2 +- api/swagger-gen.yaml | 12 ++++++++++++ api/{server => }/types/volume/volumes_create.go | 0 api/{server => }/types/volume/volumes_list.go | 0 cli/command/volume/create.go | 2 +- client/interface.go | 2 +- client/volume_create.go | 2 +- client/volume_create_test.go | 2 +- client/volume_list.go | 2 +- client/volume_list_test.go | 2 +- daemon/cluster/executor/container/container.go | 2 +- hack/generate-swagger-api.sh | 4 ++-- integration-cli/docker_api_volumes_test.go | 2 +- integration-cli/docker_utils.go | 2 +- 14 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 api/swagger-gen.yaml rename api/{server => }/types/volume/volumes_create.go (100%) rename api/{server => }/types/volume/volumes_list.go (100%) diff --git a/api/server/router/volume/volume_routes.go b/api/server/router/volume/volume_routes.go index b8a8b577a9..e0398817c3 100644 --- a/api/server/router/volume/volume_routes.go +++ b/api/server/router/volume/volume_routes.go @@ -5,8 +5,8 @@ import ( "net/http" "github.com/docker/docker/api/server/httputils" - volumetypes "github.com/docker/docker/api/server/types/volume" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) diff --git a/api/swagger-gen.yaml b/api/swagger-gen.yaml new file mode 100644 index 0000000000..f07a02737f --- /dev/null +++ b/api/swagger-gen.yaml @@ -0,0 +1,12 @@ + +layout: + models: + - name: definition + source: asset:model + target: "{{ joinFilePath .Target .ModelPackage }}" + file_name: "{{ (snakize (pascalize .Name)) }}.go" + operations: + - name: handler + source: asset:serverOperation + target: "{{ joinFilePath .Target .APIPackage .Package }}" + file_name: "{{ (snakize (pascalize .Name)) }}.go" diff --git a/api/server/types/volume/volumes_create.go b/api/types/volume/volumes_create.go similarity index 100% rename from api/server/types/volume/volumes_create.go rename to api/types/volume/volumes_create.go diff --git a/api/server/types/volume/volumes_list.go b/api/types/volume/volumes_list.go similarity index 100% rename from api/server/types/volume/volumes_list.go rename to api/types/volume/volumes_list.go diff --git a/cli/command/volume/create.go b/cli/command/volume/create.go index f16e650bbc..7b2a7e3318 100644 --- a/cli/command/volume/create.go +++ b/cli/command/volume/create.go @@ -5,7 +5,7 @@ import ( "golang.org/x/net/context" - volumetypes "github.com/docker/docker/api/server/types/volume" + volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" "github.com/docker/docker/opts" diff --git a/client/interface.go b/client/interface.go index 5ec750abe1..1f20a8be73 100644 --- a/client/interface.go +++ b/client/interface.go @@ -4,7 +4,6 @@ import ( "io" "time" - volumetypes "github.com/docker/docker/api/server/types/volume" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/events" @@ -12,6 +11,7 @@ import ( "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) diff --git a/client/volume_create.go b/client/volume_create.go index b18e5fe600..9620c87cbf 100644 --- a/client/volume_create.go +++ b/client/volume_create.go @@ -3,8 +3,8 @@ package client import ( "encoding/json" - volumetypes "github.com/docker/docker/api/server/types/volume" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) diff --git a/client/volume_create_test.go b/client/volume_create_test.go index d5d3791685..9f1b2540b5 100644 --- a/client/volume_create_test.go +++ b/client/volume_create_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" - volumetypes "github.com/docker/docker/api/server/types/volume" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) diff --git a/client/volume_list.go b/client/volume_list.go index 9923ecb82c..32247ce115 100644 --- a/client/volume_list.go +++ b/client/volume_list.go @@ -4,8 +4,8 @@ import ( "encoding/json" "net/url" - volumetypes "github.com/docker/docker/api/server/types/volume" "github.com/docker/docker/api/types/filters" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) diff --git a/client/volume_list_test.go b/client/volume_list_test.go index ffdd904b58..f29639be23 100644 --- a/client/volume_list_test.go +++ b/client/volume_list_test.go @@ -9,9 +9,9 @@ import ( "strings" "testing" - volumetypes "github.com/docker/docker/api/server/types/volume" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + volumetypes "github.com/docker/docker/api/types/volume" "golang.org/x/net/context" ) diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go index ab5b0c35b5..10b2a371f7 100644 --- a/daemon/cluster/executor/container/container.go +++ b/daemon/cluster/executor/container/container.go @@ -9,12 +9,12 @@ import ( "github.com/Sirupsen/logrus" - volumetypes "github.com/docker/docker/api/server/types/volume" "github.com/docker/docker/api/types" enginecontainer "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/network" + volumetypes "github.com/docker/docker/api/types/volume" clustertypes "github.com/docker/docker/daemon/cluster/provider" "github.com/docker/docker/reference" "github.com/docker/swarmkit/agent/exec" diff --git a/hack/generate-swagger-api.sh b/hack/generate-swagger-api.sh index 6f64d43130..c30197f435 100755 --- a/hack/generate-swagger-api.sh +++ b/hack/generate-swagger-api.sh @@ -2,7 +2,7 @@ set -eu swagger generate model -f api/swagger.yaml \ - -t api -m types --skip-validator \ + -t api -m types --skip-validator -C api/swagger-gen.yaml \ -n Volume \ -n Port \ -n ImageSummary \ @@ -10,7 +10,7 @@ swagger generate model -f api/swagger.yaml \ -n ErrorResponse swagger generate operation -f api/swagger.yaml \ - -t api -s server -a types -m types \ + -t api -a types -m types -C api/swagger-gen.yaml \ -T api/templates --skip-responses --skip-parameters --skip-validator \ -n VolumesList \ -n VolumesCreate diff --git a/integration-cli/docker_api_volumes_test.go b/integration-cli/docker_api_volumes_test.go index d7f4c6fc13..d1d44005e0 100644 --- a/integration-cli/docker_api_volumes_test.go +++ b/integration-cli/docker_api_volumes_test.go @@ -5,8 +5,8 @@ import ( "net/http" "path/filepath" - volumetypes "github.com/docker/docker/api/server/types/volume" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/pkg/integration/checker" "github.com/go-check/check" ) diff --git a/integration-cli/docker_utils.go b/integration-cli/docker_utils.go index 5adc555878..91dc88647b 100644 --- a/integration-cli/docker_utils.go +++ b/integration-cli/docker_utils.go @@ -22,8 +22,8 @@ import ( "strings" "time" - volumetypes "github.com/docker/docker/api/server/types/volume" "github.com/docker/docker/api/types" + volumetypes "github.com/docker/docker/api/types/volume" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/httputils" icmd "github.com/docker/docker/pkg/integration/cmd"