api: Allow for an empty string for Isolation in Swagger specs #48616
api: Allow for an empty string for Isolation in Swagger specs #48616thaJeztah merged 1 commit intomoby:masterfrom
Conversation
bab4ce4 to
f754f30
Compare
| - "default" | ||
| - "process" | ||
| - "hyperv" | ||
| - "" |
There was a problem hiding this comment.
Wondering if we should try if some permutation of "nullable" would work for this; it looks like it's hard to do correct in combination with enum though; OAI/OpenAPI-Specification#1900
There was a problem hiding this comment.
Hi @thaJeztah, having it nullable would be great. I am struggling to have it work successfully with an enum as well.
So far I tried:
oneOf: - type: "null" - type: "string" enum: - "default" - "process" - "hyperv"
Also tried just adding:
Isolation: type: "string" type: "null"
Isolation: type: "string" type: "nullable"
I also added nullable: true, which I think is part of openapi 3.1 I believe which did not work.
All of these still cause my test to fail, and is not recognizing null as valid.
I also noticed that one of the Isolations had a default: "default" and added that to all the different enums, but encountered the same error.
Open to other suggestions!
There was a problem hiding this comment.
Thanks! Yes, I also went looking, and it looks like options are a bit limited for Swagger / OpenAPI 2 sadly. We do have the x-nullable: true option, but I don't think that helps for this case.
Unfortunately, we're currently stuck at OpenAPI 2 (due to some go frameworks we use for these), so I think this is indeed the best we can do for now.
…ds an empty string as a valid option for the Isolation field when inspecting a container. On non windows systems, this is always empty, so no error should be returned. Fixes moby#47452 Signed-off-by: Daniel Guns <[email protected]>
f754f30 to
26049fe
Compare
|
@thaJeztah Would you be able to give the another review if you had time? Happy to try something else if there is more to be done here. |
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM
I'll do some follow-ups to put these changes in the versioned swagger files we use in our docs.
- What I did
Modified the Swagger specification to allow an empty string to be a valid option for the Isolation field when inspecting a container with code generated with these specifications. On non Windows systems this is always blank, so it should not give an error in those cases. If there is another approach I should take, or do something different please let me know! I am new to contributing to open source.
- How I did it
I updated the api/swagger.yaml to include - "" as an enum value so it no longer throws an error while inspecting the Isolation field.
- How to verify it
- Screenshots


Result of inspecting Container Before Change
Result of inspecting Container After Change
- Description for the changelog