Skip to content
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

api: swagger: Adjust ContainerWaitResponse error as optional #43656

Merged
merged 2 commits into from May 31, 2022

Conversation

fussybeaver
Copy link
Contributor

- What I did
Removed the required API swagger flag on the ContainerWaitResponse type Error property

- How I did it
Amended API 1.39, 1.40, 1.41 and the future swagger for 1.42 YAML description to remove the required flag

- How to verify it
Generated types for the Bollard docker client and ran integration tests on the new types.

- Description for the changelog
Removed the required field in the swagger documentation for the ContainerWaitResponse Error property.

fixes #43655

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah
Copy link
Member

hm, interesting, so I recall I added the required to make the generated type match the existing one. In this commit, the type that was moved, already had "Required: true" in the generated Go code; e4c6ca3

Wondering if that was a quirk in the generator that's used in this repository 🤔

@thaJeztah
Copy link
Member

Looks indeed that the generated type differs with this patch (perhaps it's ok to change though);

 The result of hack/generate-swagger-api.sh differs

 diff --git a/api/types/container/wait_response.go b/api/types/container/wait_response.go
 index d2fb63aac5..84fc6afddc 100644
 --- a/api/types/container/wait_response.go
 +++ b/api/types/container/wait_response.go
 @@ -10,8 +10,7 @@ package container
  type WaitResponse struct {
  
  	// error
 -	// Required: true
 -	Error *WaitExitError `json:"Error"`
 +	Error *WaitExitError `json:"Error,omitempty"`
  
  	// Exit code of the container
  	// Required: true

 Please update api/swagger.yaml with any API changes, then
 run hack/generate-swagger-api.sh.

@fussybeaver
Copy link
Contributor Author

To be clear, I see the field exists but is set to null in JSON on the wire. So far the Bollard client API assumes required properties to be set to a value.

There is perhaps a case to look into using the x-nullable vendor extension, but I haven't tested thoroughly whether this works in Bollard across the whole API.

@thaJeztah
Copy link
Member

thaJeztah commented May 29, 2022

Yes, to be honest; at times it's a bit tricky to pick the most suitable option in swagger, as not all of them are a "perfect fit" for the go types (combinations of "nullable" fields, "omit empty", etc). I think the change shown in the diff above (at least at a glance) looks still OK, and I don't expect that change to be causing issues from our side (or at least, i'd expect the client to unmarshal both the "before" and "after" identical), so to unblock this PR, I'd suggest to;

  • re-generate the type (or manually update it with the diff as shown above)
  • if it's not too much trouble for you; split the changes in the api/types/container/wait_response.go and api/swagger.yaml (i.e. "current version") to a separate commit

Last one gives us a bit more flexibility to decide if we want to backport only the "documentation" changes or both the documentation and code changes to the "20.10" release branch (which is the branch that's also used for the documentation at docs.docker.com)

Signed-off-by: Niel Drummond <niel@drummond.lu>
Signed-off-by: Niel Drummond <niel@drummond.lu>
@fussybeaver fussybeaver force-pushed the ND-optional-container-wait-error branch from 16abf74 to 152467d Compare May 30, 2022 16:37
@fussybeaver
Copy link
Contributor Author

I've regenerated the types with the provided make command and split the commits. Let me know if there's anything outstanding..

1 similar comment
@fussybeaver
Copy link
Contributor Author

I've regenerated the types with the provided make command and split the commits. Let me know if there's anything outstanding..

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thaJeztah
Copy link
Member

thaJeztah commented May 31, 2022

CI failure is unrelated; I kicked the Windows CI once more, but this should be ready to merge 👍

=== Failed
=== FAIL: cmd/docker-proxy TestSCTP4Proxy (0.26s)
2022/05/30 16:55:48 Can't forward traffic to backend sctp/127.0.0.1:35806: transport endpoint is already connected
    network_proxy_test.go:161: EOF

@thaJeztah
Copy link
Member

alright; good to go; thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API doc for ContainerWaitResponse required field that is optional
3 participants