Skip to content

swagger is not specifying the required property for several definitions #51710

@axel7083

Description

@axel7083

Description

I was exploring ways of generating types from the existing api/swagger.yaml definition to explore alternative to the dockerode project (JS client for the Engine api) using the swagger as the single source of truth and swagger-typescript-api.

However I faced some some unfortunate results as some definitions are not specifying required properties, and by default it will be seen as optional. For example the ContainerSummary schema does not specify required field, therefore this is pretty difficult to determine what is mandatory and what is optional.

Some properties are specifying the x-nullable for example

moby/api/swagger.yaml

Lines 5428 to 5430 in 70aa2e2

ImageManifestDescriptor:
$ref: "#/definitions/OCIDescriptor"
x-nullable: true

From my understanding, this only mean that this may be null, not that the property is sure to be in the object.

Reproduce

N/A

Expected behavior

I would expect to see the required property to specify mandatory properties.

docker version

N/A

docker info

N/A

Additional Info

Made a quick script to find all definitions of type object without a required property

119/146 object without required:

  • MountPoint
  • DeviceMapping
  • DeviceRequest
  • ThrottleDevice
  • Mount
  • RestartPolicy
  • Resources
  • Limit
  • ResourceObject
  • HealthConfig
  • Health
  • HealthcheckResult
  • ContainerConfig
  • ImageConfig
  • NetworkingConfig
  • NetworkSettings
  • Address
  • PortMap
  • PortBinding
  • Storage
  • RootFSStorage
  • RootFSStorageSnapshot
  • ImageInspect
  • ImagesDiskUsage
  • AuthConfig
  • ProcessConfig
  • VolumesDiskUsage
  • VolumeCreateRequest
  • VolumeListResponse
  • Network
  • NetworkSummary
  • NetworkInspect
  • NetworkStatus
  • ServiceInfo
  • NetworkTaskInfo
  • ConfigReference
  • IPAM
  • IPAMConfig
  • IPAMStatus
  • SubnetStatus
  • EndpointResource
  • PeerInfo
  • BuildInfo
  • BuildCache
  • BuildCacheDiskUsage
  • ImageID
  • CreateImageInfo
  • PushImageInfo
  • DeviceInfo
  • ErrorDetail
  • ProgressDetail
  • EndpointSettings
  • EndpointIPAMConfig
  • PluginPrivilege
  • ObjectVersion
  • NodeSpec
  • Node
  • NodeDescription
  • Platform
  • EngineDescription
  • TLSInfo
  • NodeStatus
  • ManagerStatus
  • SwarmSpec
  • ClusterInfo
  • JoinTokens
  • Swarm
  • TaskSpec
  • ContainerStatus
  • PortStatus
  • TaskStatus
  • Task
  • ServiceSpec
  • EndpointPortConfig
  • EndpointSpec
  • Service
  • ImageDeleteResponseItem
  • ServiceCreateResponse
  • ServiceUpdateResponse
  • ContainerInspectResponse
  • ContainerSummary
  • ContainersDiskUsage
  • SecretSpec
  • Secret
  • ConfigSpec
  • Config
  • ContainerState
  • ContainerUpdateResponse
  • ContainerStatsResponse
  • ContainerBlkioStats
  • ContainerBlkioStatEntry
  • ContainerCPUStats
  • ContainerCPUUsage
  • ContainerPidsStats
  • ContainerThrottlingData
  • ContainerMemoryStats
  • ContainerNetworkStats
  • ContainerStorageStats
  • ContainerTopResponse
  • ContainerWaitExitError
  • SystemVersion
  • SystemInfo
  • ContainerdInfo
  • FirewallInfo
  • PluginsInfo
  • RegistryServiceConfig
  • IndexInfo
  • Runtime
  • Commit
  • SwarmInfo
  • PeerNode
  • NetworkAttachmentConfig
  • EventActor
  • EventMessage
  • OCIDescriptor
  • OCIPlatform
  • ClusterVolume
  • ClusterVolumeSpec
  • Topology

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiAPIkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.module/apistatus/0-triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions