Browse code

Use a config to generate swagger api types

Moves the resposne types to a package under api/types

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2016/10/15 05:20:13
Showing 16 changed files
... ...
@@ -5,8 +5,8 @@ import (
5 5
 	"net/http"
6 6
 
7 7
 	"github.com/docker/docker/api/server/httputils"
8
-	volumetypes "github.com/docker/docker/api/server/types/volume"
9 8
 	"github.com/docker/docker/api/types"
9
+	volumetypes "github.com/docker/docker/api/types/volume"
10 10
 	"golang.org/x/net/context"
11 11
 )
12 12
 
13 13
deleted file mode 100644
... ...
@@ -1,29 +0,0 @@
1
-package volume
2
-
3
-// ----------------------------------------------------------------------------
4
-// DO NOT EDIT THIS FILE
5
-// This file was generated by `swagger generate operation`
6
-//
7
-// See hack/swagger-gen.sh
8
-// ----------------------------------------------------------------------------
9
-
10
-// VolumesCreateBody volumes create body
11
-// swagger:model VolumesCreateBody
12
-type VolumesCreateBody struct {
13
-
14
-	// Name of the volume driver to use.
15
-	// Required: true
16
-	Driver string `json:"Driver"`
17
-
18
-	// A mapping of driver options and values. These options are passed directly to the driver and are driver specific.
19
-	// Required: true
20
-	DriverOpts map[string]string `json:"DriverOpts"`
21
-
22
-	// A mapping of arbitrary key/value data to set on the volume.
23
-	// Required: true
24
-	Labels map[string]string `json:"Labels"`
25
-
26
-	// The new volume's name. If not specified, Docker generates a name.
27
-	// Required: true
28
-	Name string `json:"Name"`
29
-}
30 1
deleted file mode 100644
... ...
@@ -1,23 +0,0 @@
1
-package volume
2
-
3
-// ----------------------------------------------------------------------------
4
-// DO NOT EDIT THIS FILE
5
-// This file was generated by `swagger generate operation`
6
-//
7
-// See hack/swagger-gen.sh
8
-// ----------------------------------------------------------------------------
9
-
10
-import "github.com/docker/docker/api/types"
11
-
12
-// VolumesListOKBody volumes list o k body
13
-// swagger:model VolumesListOKBody
14
-type VolumesListOKBody struct {
15
-
16
-	// List of volumes
17
-	// Required: true
18
-	Volumes []*types.Volume `json:"Volumes"`
19
-
20
-	// Warnings that occurred when fetching the list of volumes
21
-	// Required: true
22
-	Warnings []string `json:"Warnings"`
23
-}
24 1
new file mode 100644
... ...
@@ -0,0 +1,12 @@
0
+
1
+layout:
2
+  models:
3
+    - name: definition
4
+      source: asset:model
5
+      target: "{{ joinFilePath .Target .ModelPackage }}"
6
+      file_name: "{{ (snakize (pascalize .Name)) }}.go"
7
+  operations:
8
+    - name: handler
9
+      source: asset:serverOperation
10
+      target: "{{ joinFilePath .Target .APIPackage .Package }}"
11
+      file_name: "{{ (snakize (pascalize .Name)) }}.go"
0 12
new file mode 100644
... ...
@@ -0,0 +1,29 @@
0
+package volume
1
+
2
+// ----------------------------------------------------------------------------
3
+// DO NOT EDIT THIS FILE
4
+// This file was generated by `swagger generate operation`
5
+//
6
+// See hack/swagger-gen.sh
7
+// ----------------------------------------------------------------------------
8
+
9
+// VolumesCreateBody volumes create body
10
+// swagger:model VolumesCreateBody
11
+type VolumesCreateBody struct {
12
+
13
+	// Name of the volume driver to use.
14
+	// Required: true
15
+	Driver string `json:"Driver"`
16
+
17
+	// A mapping of driver options and values. These options are passed directly to the driver and are driver specific.
18
+	// Required: true
19
+	DriverOpts map[string]string `json:"DriverOpts"`
20
+
21
+	// A mapping of arbitrary key/value data to set on the volume.
22
+	// Required: true
23
+	Labels map[string]string `json:"Labels"`
24
+
25
+	// The new volume's name. If not specified, Docker generates a name.
26
+	// Required: true
27
+	Name string `json:"Name"`
28
+}
0 29
new file mode 100644
... ...
@@ -0,0 +1,23 @@
0
+package volume
1
+
2
+// ----------------------------------------------------------------------------
3
+// DO NOT EDIT THIS FILE
4
+// This file was generated by `swagger generate operation`
5
+//
6
+// See hack/swagger-gen.sh
7
+// ----------------------------------------------------------------------------
8
+
9
+import "github.com/docker/docker/api/types"
10
+
11
+// VolumesListOKBody volumes list o k body
12
+// swagger:model VolumesListOKBody
13
+type VolumesListOKBody struct {
14
+
15
+	// List of volumes
16
+	// Required: true
17
+	Volumes []*types.Volume `json:"Volumes"`
18
+
19
+	// Warnings that occurred when fetching the list of volumes
20
+	// Required: true
21
+	Warnings []string `json:"Warnings"`
22
+}
... ...
@@ -5,7 +5,7 @@ import (
5 5
 
6 6
 	"golang.org/x/net/context"
7 7
 
8
-	volumetypes "github.com/docker/docker/api/server/types/volume"
8
+	volumetypes "github.com/docker/docker/api/types/volume"
9 9
 	"github.com/docker/docker/cli"
10 10
 	"github.com/docker/docker/cli/command"
11 11
 	"github.com/docker/docker/opts"
... ...
@@ -4,7 +4,6 @@ import (
4 4
 	"io"
5 5
 	"time"
6 6
 
7
-	volumetypes "github.com/docker/docker/api/server/types/volume"
8 7
 	"github.com/docker/docker/api/types"
9 8
 	"github.com/docker/docker/api/types/container"
10 9
 	"github.com/docker/docker/api/types/events"
... ...
@@ -12,6 +11,7 @@ import (
12 12
 	"github.com/docker/docker/api/types/network"
13 13
 	"github.com/docker/docker/api/types/registry"
14 14
 	"github.com/docker/docker/api/types/swarm"
15
+	volumetypes "github.com/docker/docker/api/types/volume"
15 16
 	"golang.org/x/net/context"
16 17
 )
17 18
 
... ...
@@ -3,8 +3,8 @@ package client
3 3
 import (
4 4
 	"encoding/json"
5 5
 
6
-	volumetypes "github.com/docker/docker/api/server/types/volume"
7 6
 	"github.com/docker/docker/api/types"
7
+	volumetypes "github.com/docker/docker/api/types/volume"
8 8
 	"golang.org/x/net/context"
9 9
 )
10 10
 
... ...
@@ -9,8 +9,8 @@ import (
9 9
 	"strings"
10 10
 	"testing"
11 11
 
12
-	volumetypes "github.com/docker/docker/api/server/types/volume"
13 12
 	"github.com/docker/docker/api/types"
13
+	volumetypes "github.com/docker/docker/api/types/volume"
14 14
 	"golang.org/x/net/context"
15 15
 )
16 16
 
... ...
@@ -4,8 +4,8 @@ import (
4 4
 	"encoding/json"
5 5
 	"net/url"
6 6
 
7
-	volumetypes "github.com/docker/docker/api/server/types/volume"
8 7
 	"github.com/docker/docker/api/types/filters"
8
+	volumetypes "github.com/docker/docker/api/types/volume"
9 9
 	"golang.org/x/net/context"
10 10
 )
11 11
 
... ...
@@ -9,9 +9,9 @@ import (
9 9
 	"strings"
10 10
 	"testing"
11 11
 
12
-	volumetypes "github.com/docker/docker/api/server/types/volume"
13 12
 	"github.com/docker/docker/api/types"
14 13
 	"github.com/docker/docker/api/types/filters"
14
+	volumetypes "github.com/docker/docker/api/types/volume"
15 15
 	"golang.org/x/net/context"
16 16
 )
17 17
 
... ...
@@ -9,12 +9,12 @@ import (
9 9
 
10 10
 	"github.com/Sirupsen/logrus"
11 11
 
12
-	volumetypes "github.com/docker/docker/api/server/types/volume"
13 12
 	"github.com/docker/docker/api/types"
14 13
 	enginecontainer "github.com/docker/docker/api/types/container"
15 14
 	"github.com/docker/docker/api/types/events"
16 15
 	"github.com/docker/docker/api/types/filters"
17 16
 	"github.com/docker/docker/api/types/network"
17
+	volumetypes "github.com/docker/docker/api/types/volume"
18 18
 	clustertypes "github.com/docker/docker/daemon/cluster/provider"
19 19
 	"github.com/docker/docker/reference"
20 20
 	"github.com/docker/swarmkit/agent/exec"
... ...
@@ -2,7 +2,7 @@
2 2
 set -eu
3 3
 
4 4
 swagger generate model -f api/swagger.yaml \
5
-    -t api -m types --skip-validator \
5
+    -t api -m types --skip-validator -C api/swagger-gen.yaml \
6 6
     -n Volume \
7 7
     -n Port \
8 8
     -n ImageSummary \
... ...
@@ -10,7 +10,7 @@ swagger generate model -f api/swagger.yaml \
10 10
     -n ErrorResponse
11 11
 
12 12
 swagger generate operation -f api/swagger.yaml \
13
-    -t api -s server -a types -m types \
13
+    -t api -a types -m types -C api/swagger-gen.yaml \
14 14
     -T api/templates --skip-responses --skip-parameters --skip-validator \
15 15
     -n VolumesList \
16 16
     -n VolumesCreate
... ...
@@ -5,8 +5,8 @@ import (
5 5
 	"net/http"
6 6
 	"path/filepath"
7 7
 
8
-	volumetypes "github.com/docker/docker/api/server/types/volume"
9 8
 	"github.com/docker/docker/api/types"
9
+	volumetypes "github.com/docker/docker/api/types/volume"
10 10
 	"github.com/docker/docker/pkg/integration/checker"
11 11
 	"github.com/go-check/check"
12 12
 )
... ...
@@ -22,8 +22,8 @@ import (
22 22
 	"strings"
23 23
 	"time"
24 24
 
25
-	volumetypes "github.com/docker/docker/api/server/types/volume"
26 25
 	"github.com/docker/docker/api/types"
26
+	volumetypes "github.com/docker/docker/api/types/volume"
27 27
 	"github.com/docker/docker/opts"
28 28
 	"github.com/docker/docker/pkg/httputils"
29 29
 	icmd "github.com/docker/docker/pkg/integration/cmd"