-
Notifications
You must be signed in to change notification settings - Fork 18.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve swagger.yaml to match the 1.41 api version #42621
Conversation
Looks like I failed to actually validate the yaml file (the validate job fails):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! Changes look ok; I left a comment on how to fix the failing validation; if you can amend that commit to fix it
type: "array" | ||
items: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this definition is referenced in two places in the swagger;
/system/df
->responses.200.Containers
which uses it as items in an array; so the swagger incorrectly defined it as an "array of arrays"/containers/json
->responses -> 200
which used it directly, so an "array of objects"
I think your change makes sense; i.e. change ContainerSummary
to an object (not an array of objects), so to make swagger validation pass, the /containers/json
response needs to be updated.
If you amend the third commit ("Fix ContainerSummary swagger docs ") with the patch below, swagger validation should pass:
diff --git a/api/swagger.yaml b/api/swagger.yaml
index fa71b38f09..efa2b81587 100644
--- a/api/swagger.yaml
+++ b/api/swagger.yaml
@@ -5261,7 +5261,9 @@ paths:
200:
description: "no error"
schema:
- $ref: "#/definitions/ContainerSummary"
+ type: "array"
+ items:
+ $ref: "#/definitions/ContainerSummary"
examples:
application/json:
- Id: "8dfafdbc3a40"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion, looks perfect. I just applied your patch, let's see what the CI will find :)
Now the validation step reports a diff like this: diff --git a/api/types/container/container_wait.go b/api/types/container/container_wait.go
index 49e05ae669..c2e69b5b25 100644
--- a/api/types/container/container_wait.go
+++ b/api/types/container/container_wait.go
@@ -6,14 +6,6 @@ package container // import "github.com/docker/docker/api/types/container"
// 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 {
@@ -26,3 +18,11 @@ type ContainerWaitOKBody struct {
// Required: true
StatusCode int64 `json:"StatusCode"`
}
+
+// ContainerWaitOKBodyError container waiting error, if any
+// swagger:model ContainerWaitOKBodyError
+type ContainerWaitOKBodyError struct {
+
+ // Details of an error
+ Message string `json:"Message,omitempty"`
+} This one looks like the struct has only moved down, but its content isn't changed. I added another commit to apply the codegen's changes. |
Will the CI retry automatically on errors like this?
|
Ah, dang, sorry, I should've mentioned. That's flakiness in the code generator. For We know about that failure, so will just trigger CI again if it fails because of that (but should try to get rid of the old go-swagger version) 😓 could you remove the last commit again? 🤗
Hmmm.. not it doesn't automatically; I noticed the same error earlier today on another PR (but restarting fixed it). Looks like there may be an issue with their package repository (or an issue with some of our CI nodes). |
Ah alright, yes, I've removed the last commit 😌 |
|
Thank you! Sorry for that.
Yes. I see it succeeded on some machines, but failed on other machines. Looking at the
Never say never of course; let me delete the failing Jenkins node (in case it's something on a specific machine), just to be sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
to other reviewers; use ?w=1
to view the diff without the whitespace changes; https://github.com/moby/moby/pull/42621/files?w=1
@AkihiroSuda @rvolosatovs ptal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Since I'm still working on an api client with model classes generated from the swagger.yaml, I could add more improvements similar to the forth commit (naming inlined objects so that generated code is more expressive). I can add the additional changes here or would you prefer me to create another pull request? I also filed an issue to discuss another topic ( Edit: I added another commit ff35e40 with explicit type names and a consolidated |
api/swagger.yaml
Outdated
the plugin. | ||
type: "object" | ||
x-nullable: false | ||
required: [Name, Value] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope adding the x-nullable: false
and the required
contrains don't break anything - or do they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think x-nullable: false
would be the default, or is it not? If so, I guess it can be removed 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to leave it for a separate PR? That could (a bit) simplify the review at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the change and will create another PR.
@thaJeztah you certainly have more important tasks to do, yet I wanted to ask if you could give some rough feedback on the recent changes. I'd like to know if this is a good direction or if there's anything to fix. The CI run doesn't appear to be related, but you might have more insights. Like mentioned above: I'm working on a clean code generated api model, and the changes in this pull request are only the easy ones, while #42632 is probably more challenging due to a changed api (maybe). I would be glad if such kind of cleanup of the swagger docs and the api itself could be inlcuded in the upcoming v1.42 :) |
ping? |
@thaJeztah @AkihiroSuda @rvolosatovs would anyone like to have a look at the recent commit? I'd like to cleanup the pull request, so that it could get a final review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM
@@ -2190,6 +2190,26 @@ definitions: | |||
type: "string" | |||
x-nullable: false | |||
|
|||
PluginPrivilegeItem: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraction of this type definition should probably better be done in a separate commit
api/swagger.yaml
Outdated
@@ -7507,6 +7507,12 @@ paths: | |||
Refer to the [authentication section](#section/Authentication) for | |||
details. | |||
type: "string" | |||
- name: "changes" | |||
in: "query" | |||
description: "Apply Dockerfile instruction to the created image." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not very clear to me what this does given the description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was taken from the CLI docs (see https://github.com/docker/cli/blob/c758c3e4a5a980cf0ea3292c958fd537822ba0d5/docs/reference/commandline/import.md#description), trying to keep some consistency. Yet, the cli docs are more specific regarding the supported Dockerfile commands.
I changed the description to be more detailed.
api/swagger.yaml
Outdated
the plugin. | ||
type: "object" | ||
x-nullable: false | ||
required: [Name, Value] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to leave it for a separate PR? That could (a bit) simplify the review at least
Signed-off-by: Tobias Gesellchen <tobias@gesellix.de>
Signed-off-by: Tobias Gesellchen <tobias@gesellix.de>
Signed-off-by: Tobias Gesellchen <tobias@gesellix.de>
Signed-off-by: Tobias Gesellchen <tobias@gesellix.de>
Signed-off-by: Tobias Gesellchen <tobias@gesellix.de>
Signed-off-by: Tobias Gesellchen <tobias@gesellix.de>
@rvolosatovs From my perspective this one is ready for a final review. Please leave a suggestion if the description for |
The failing CI checks don't seem to be related to my changes, or do they? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arf, I see I was writing a review, but didn't submit it.
Changes LGTM, thanks!
I see some of my comments are now outdated, and I was working on some other changes, so let me get this one merged.
api/swagger.yaml
Outdated
the plugin. | ||
type: "object" | ||
x-nullable: false | ||
required: [Name, Value] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think x-nullable: false
would be the default, or is it not? If so, I guess it can be removed 🤔
type: "array" | ||
items: | ||
type: "string" | ||
Variant: | ||
variant: | ||
type: "string" | ||
Features: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this one can be removed now.
I was working on some other changes, and can include that in a follow-up
Thanks for merging! I'm still not finished with the overall improvement for the swagger.yaml, but the upcoming changes might be harder/riskier than the ones in this PR. |
I recently tried to rely on the swagger.yaml for code generation of an api client. Some parts required manual fixes of the swagger docs to match the current api version 1.41.
All changes described below relate to a dedicated commit, because they aim at different parts of the api description and aren't releated per se. If you'd prefer to merge them all into a single commit, please leave a note.
- What I did
- How I did it
Used the 1.41 swagger.yaml with swagger's codegen to generate Java code. Used that code to perform requests to a 1.41 Docker engine. Applied some fixes and
hack/validate/swagger
andmake swagger-docs
to validate the changes.- How to verify it
Compare the actual 1.41 api with the swagger.yaml.
- Description for the changelog
Update the swagger.yaml to match the version 1.41 api.
- A picture of a cute animal (not mandatory but encouraged)