You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the Docker::list_containers method to list all existing containers, which returns a list of ContainerSummary values.
But every field of that struct is wrapped in an Option! For instance, even the container's ID is declared as id: Option<String>. Why is that?
I'm curious to know the reason why we need to unwrap these values every time, isn't the underlying socket method guaranteed to return some informations like the ID?
The text was updated successfully, but these errors were encountered:
The majority of the models are generated from the upstream moby project, which releases openapi version 2.0 swagger schema against the API that is released.
OpenAPI version 2 has the required key to determine whether something is required https://json-schema.org/draft/2020-12/json-schema-validation.html#name-required . I think there's a case to unwrap optionals if we see these, but at least for now we don't do that yet. Initially this library focused on stability on the API, so this wasn't implemented out of caution.
I think it'd be useful to have an implementation, perhaps initially feature flagged, that generates required fields without an optional, if anyone is interested to work on it.
AFAIK (I could be wrong) the required property is only for input fields, not output. Output fields are always considered required unless the nullable descriptor is provided.
Which seems logical since it would make no sense to have no guaranteed field on a stable API.
I used the
Docker::list_containers
method to list all existing containers, which returns a list ofContainerSummary
values.But every field of that struct is wrapped in an
Option
! For instance, even the container's ID is declared asid: Option<String>
. Why is that?I'm curious to know the reason why we need to unwrap these values every time, isn't the underlying socket method guaranteed to return some informations like the ID?
The text was updated successfully, but these errors were encountered: