From 0119f7973b75378491653b0e025ca1b63ce58e4f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 5 Mar 2022 15:31:04 +0100 Subject: [PATCH] api: swagger: move VolumeCreateOptions to definitions Signed-off-by: Sebastiaan van Stijn --- api/swagger.yaml | 71 ++++++++++++++------------ api/types/volume/volume_create.go | 31 ----------- api/types/volume/volume_create_body.go | 26 ++++++++++ hack/generate-swagger-api.sh | 5 +- 4 files changed, 69 insertions(+), 64 deletions(-) delete mode 100644 api/types/volume/volume_create.go create mode 100644 api/types/volume/volume_create_body.go diff --git a/api/swagger.yaml b/api/swagger.yaml index 00a8dd255a..67028c3ba4 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -1907,6 +1907,44 @@ definitions: is set to `-1` if the reference-count is not available. 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: type: "object" properties: @@ -9053,38 +9091,7 @@ paths: required: true description: "Volume configuration" 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"] /volumes/{name}: diff --git a/api/types/volume/volume_create.go b/api/types/volume/volume_create.go deleted file mode 100644 index 8538078dd6..0000000000 --- a/api/types/volume/volume_create.go +++ /dev/null @@ -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"` -} diff --git a/api/types/volume/volume_create_body.go b/api/types/volume/volume_create_body.go new file mode 100644 index 0000000000..f40fe1377f --- /dev/null +++ b/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"` +} diff --git a/hack/generate-swagger-api.sh b/hack/generate-swagger-api.sh index 90a01df027..9a54cf9c97 100755 --- a/hack/generate-swagger-api.sh +++ b/hack/generate-swagger-api.sh @@ -13,6 +13,10 @@ swagger generate model -f api/swagger.yaml \ -n ServiceUpdateResponse \ -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 \ -t api -a types -m types -C api/swagger-gen.yaml \ -T api/templates --skip-responses --skip-parameters --skip-validator \ @@ -23,5 +27,4 @@ swagger generate operation -f api/swagger.yaml \ -n ContainerUpdate \ -n ContainerWait \ -n ImageHistory \ - -n VolumeCreate \ -n VolumeList