From e4c6ca36aea01bfebe34d09c728e60ebe35a0442 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 5 Mar 2022 17:02:03 +0100 Subject: [PATCH] api: swagger: move ContainerWaitResponse to definitions This should help with CI being unstable when generating the types (due to Go randomizing order). Unfortunately, the (file) names are a bit ugly, but addressing that in a follow-up. Signed-off-by: Sebastiaan van Stijn --- api/swagger.yaml | 40 +++++++++++-------- api/types/container/container_wait.go | 28 ------------- .../container/container_wait_o_k_body.go | 19 +++++++++ .../container_wait_o_k_body_error.go | 12 ++++++ hack/generate-swagger-api.sh | 6 ++- 5 files changed, 60 insertions(+), 45 deletions(-) delete mode 100644 api/types/container/container_wait.go create mode 100644 api/types/container/container_wait_o_k_body.go create mode 100644 api/types/container/container_wait_o_k_body_error.go diff --git a/api/swagger.yaml b/api/swagger.yaml index 67028c3ba4..1c799db4b8 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -4460,6 +4460,29 @@ definitions: Health: $ref: "#/definitions/Health" + ContainerWaitResponse: + description: "OK response to ContainerWait operation" + type: "object" + x-go-name: "ContainerWaitOKBody" + title: "ContainerWaitResponse" + required: [StatusCode, Error] + properties: + StatusCode: + description: "Exit code of the container" + type: "integer" + x-nullable: false + Error: + $ref: "#/definitions/ContainerWaitExitError" + + ContainerWaitExitError: + description: "container waiting error, if any" + type: "object" + x-go-name: "ContainerWaitOKBodyError" + properties: + Message: + description: "Details of an error" + type: "string" + SystemVersion: type: "object" description: | @@ -7192,22 +7215,7 @@ paths: 200: description: "The container has exit." schema: - type: "object" - title: "ContainerWaitResponse" - description: "OK response to ContainerWait operation" - required: [StatusCode] - properties: - StatusCode: - description: "Exit code of the container" - type: "integer" - x-nullable: false - Error: - description: "container waiting error, if any" - type: "object" - properties: - Message: - description: "Details of an error" - type: "string" + $ref: "#/definitions/ContainerWaitResponse" 400: description: "bad parameter" schema: diff --git a/api/types/container/container_wait.go b/api/types/container/container_wait.go deleted file mode 100644 index 49e05ae669..0000000000 --- a/api/types/container/container_wait.go +++ /dev/null @@ -1,28 +0,0 @@ -package container // import "github.com/docker/docker/api/types/container" - -// ---------------------------------------------------------------------------- -// Code generated by `swagger generate operation`. DO NOT EDIT. -// -// See hack/generate-swagger-api.sh -// ---------------------------------------------------------------------------- - -// ContainerWaitOKBodyError container waiting error, if any -// swagger:model ContainerWaitOKBodyError -type ContainerWaitOKBodyError struct { - - // Details of an error - Message string `json:"Message,omitempty"` -} - -// ContainerWaitOKBody OK response to ContainerWait operation -// swagger:model ContainerWaitOKBody -type ContainerWaitOKBody struct { - - // error - // Required: true - Error *ContainerWaitOKBodyError `json:"Error"` - - // Exit code of the container - // Required: true - StatusCode int64 `json:"StatusCode"` -} diff --git a/api/types/container/container_wait_o_k_body.go b/api/types/container/container_wait_o_k_body.go new file mode 100644 index 0000000000..3219207fbb --- /dev/null +++ b/api/types/container/container_wait_o_k_body.go @@ -0,0 +1,19 @@ +package container + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// ContainerWaitOKBody ContainerWaitResponse +// +// OK response to ContainerWait operation +// swagger:model ContainerWaitOKBody +type ContainerWaitOKBody struct { + + // error + // Required: true + Error *ContainerWaitOKBodyError `json:"Error"` + + // Exit code of the container + // Required: true + StatusCode int64 `json:"StatusCode"` +} diff --git a/api/types/container/container_wait_o_k_body_error.go b/api/types/container/container_wait_o_k_body_error.go new file mode 100644 index 0000000000..ee598973ec --- /dev/null +++ b/api/types/container/container_wait_o_k_body_error.go @@ -0,0 +1,12 @@ +package container + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// ContainerWaitOKBodyError container waiting error, if any +// swagger:model ContainerWaitOKBodyError +type ContainerWaitOKBodyError struct { + + // Details of an error + Message string `json:"Message,omitempty"` +} diff --git a/hack/generate-swagger-api.sh b/hack/generate-swagger-api.sh index 9a54cf9c97..e300212e35 100755 --- a/hack/generate-swagger-api.sh +++ b/hack/generate-swagger-api.sh @@ -13,6 +13,11 @@ swagger generate model -f api/swagger.yaml \ -n ServiceUpdateResponse \ -n Volume +swagger generate model -f api/swagger.yaml \ + -t api -m types/container --skip-validator -C api/swagger-gen.yaml \ + -n ContainerWaitResponse \ + -n ContainerWaitExitError + swagger generate model -f api/swagger.yaml \ -t api -m types/volume --skip-validator -C api/swagger-gen.yaml \ -n VolumeCreateOptions @@ -25,6 +30,5 @@ swagger generate operation -f api/swagger.yaml \ -n ContainerCreate \ -n ContainerTop \ -n ContainerUpdate \ - -n ContainerWait \ -n ImageHistory \ -n VolumeList