Explorar o código

api: swagger: move VolumeCreateOptions to definitions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn %!s(int64=3) %!d(string=hai) anos
pai
achega
0119f7973b

+ 39 - 32
api/swagger.yaml

@@ -1907,6 +1907,44 @@ definitions:
               is set to `-1` if the reference-count is not available.
               is set to `-1` if the reference-count is not available.
             x-nullable: false
             x-nullable: false
 
 
+  VolumeCreateOptions:
+    description: "Volume configuration"
+    type: "object"
+    title: "VolumeConfig"
+    x-go-name: "VolumeCreateBody"
+    properties:
+      Name:
+        description: |
+          The new volume's name. If not specified, Docker generates a name.
+        type: "string"
+        x-nullable: false
+        example: "tardis"
+      Driver:
+        description: "Name of the volume driver to use."
+        type: "string"
+        default: "local"
+        x-nullable: false
+        example: "custom"
+      DriverOpts:
+        description: |
+          A mapping of driver options and values. These options are
+          passed directly to the driver and are driver specific.
+        type: "object"
+        additionalProperties:
+          type: "string"
+        example:
+          device: "tmpfs"
+          o: "size=100m,uid=1000"
+          type: "tmpfs"
+      Labels:
+        description: "User-defined key/value metadata."
+        type: "object"
+        additionalProperties:
+          type: "string"
+        example:
+          com.example.some-label: "some-value"
+          com.example.some-other-label: "some-other-value"
+
   Network:
   Network:
     type: "object"
     type: "object"
     properties:
     properties:
@@ -9053,38 +9091,7 @@ paths:
           required: true
           required: true
           description: "Volume configuration"
           description: "Volume configuration"
           schema:
           schema:
-            type: "object"
-            description: "Volume configuration"
-            title: "VolumeConfig"
-            properties:
-              Name:
-                description: |
-                  The new volume's name. If not specified, Docker generates a name.
-                type: "string"
-                x-nullable: false
-              Driver:
-                description: "Name of the volume driver to use."
-                type: "string"
-                default: "local"
-                x-nullable: false
-              DriverOpts:
-                description: |
-                  A mapping of driver options and values. These options are
-                  passed directly to the driver and are driver specific.
-                type: "object"
-                additionalProperties:
-                  type: "string"
-              Labels:
-                description: "User-defined key/value metadata."
-                type: "object"
-                additionalProperties:
-                  type: "string"
-            example:
-              Name: "tardis"
-              Labels:
-                com.example.some-label: "some-value"
-                com.example.some-other-label: "some-other-value"
-              Driver: "custom"
+            $ref: "#/definitions/VolumeCreateOptions"
       tags: ["Volume"]
       tags: ["Volume"]
 
 
   /volumes/{name}:
   /volumes/{name}:

+ 0 - 31
api/types/volume/volume_create.go

@@ -1,31 +0,0 @@
-package volume // import "github.com/docker/docker/api/types/volume"
-
-// ----------------------------------------------------------------------------
-// Code generated by `swagger generate operation`. DO NOT EDIT.
-//
-// See hack/generate-swagger-api.sh
-// ----------------------------------------------------------------------------
-
-// VolumeCreateBody Volume configuration
-// swagger:model VolumeCreateBody
-type VolumeCreateBody struct {
-
-	// Name of the volume driver to use.
-	// Required: true
-	Driver string `json:"Driver"`
-
-	// A mapping of driver options and values. These options are
-	// passed directly to the driver and are driver specific.
-	//
-	// Required: true
-	DriverOpts map[string]string `json:"DriverOpts"`
-
-	// User-defined key/value metadata.
-	// Required: true
-	Labels map[string]string `json:"Labels"`
-
-	// The new volume's name. If not specified, Docker generates a name.
-	//
-	// Required: true
-	Name string `json:"Name"`
-}

+ 26 - 0
api/types/volume/volume_create_body.go

@@ -0,0 +1,26 @@
+package volume
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+// VolumeCreateBody VolumeConfig
+//
+// Volume configuration
+// swagger:model VolumeCreateBody
+type VolumeCreateBody struct {
+
+	// Name of the volume driver to use.
+	Driver string `json:"Driver,omitempty"`
+
+	// A mapping of driver options and values. These options are
+	// passed directly to the driver and are driver specific.
+	//
+	DriverOpts map[string]string `json:"DriverOpts,omitempty"`
+
+	// User-defined key/value metadata.
+	Labels map[string]string `json:"Labels,omitempty"`
+
+	// The new volume's name. If not specified, Docker generates a name.
+	//
+	Name string `json:"Name,omitempty"`
+}

+ 4 - 1
hack/generate-swagger-api.sh

@@ -13,6 +13,10 @@ swagger generate model -f api/swagger.yaml \
 	-n ServiceUpdateResponse \
 	-n ServiceUpdateResponse \
 	-n Volume
 	-n Volume
 
 
+swagger generate model -f api/swagger.yaml \
+	-t api -m types/volume --skip-validator -C api/swagger-gen.yaml \
+	-n VolumeCreateOptions
+
 swagger generate operation -f api/swagger.yaml \
 swagger generate operation -f api/swagger.yaml \
 	-t api -a types -m types -C api/swagger-gen.yaml \
 	-t api -a types -m types -C api/swagger-gen.yaml \
 	-T api/templates --skip-responses --skip-parameters --skip-validator \
 	-T api/templates --skip-responses --skip-parameters --skip-validator \
@@ -23,5 +27,4 @@ swagger generate operation -f api/swagger.yaml \
 	-n ContainerUpdate \
 	-n ContainerUpdate \
 	-n ContainerWait \
 	-n ContainerWait \
 	-n ImageHistory \
 	-n ImageHistory \
-	-n VolumeCreate \
 	-n VolumeList
 	-n VolumeList