Skip to content

Commit bb07daa

Browse files
committed
docs/api: document /_ping?capabilities=n endpoint
We've added a query parameter `capabilities` to the `/_ping` endpoint that allows clients to request capabilities that the engine supports in the `/_ping` response. Document this change in `docs/api/version-history.md`, and update the swagger yaml accordingly. For Swagger, I've added a "separate" endpoint documenting the new behavior. This has to do with Swagger not supporting different responses for the same path (either based on query params or content-types/other headers) – see [OAI/OpenAPI-Specification#146](OAI/OpenAPI-Specification#146). This is supported in OpenAPI 3.0 [(OAI/OpenAPI-Specification#146 (comment)](OAI/OpenAPI-Specification#146 (comment))), so we could fix this up in the future. Signed-off-by: Laura Brehm <[email protected]>
1 parent d2e97d5 commit bb07daa

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

api/swagger.yaml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,36 @@ tags:
173173
x-displayName: "System"
174174

175175
definitions:
176+
Capabilities:
177+
x-extendedDiscriminator: _v
178+
description: "Represents engine capabilities"
179+
type: "object"
180+
required:
181+
- _v
182+
properties:
183+
_v:
184+
type: "integer"
185+
data:
186+
type: "object"
187+
188+
CapabilitiesV1:
189+
allOf:
190+
- $ref: "#/definitions/Capabilities"
191+
- type: "object"
192+
properties:
193+
_v:
194+
type: "integer"
195+
enum:
196+
- 1
197+
data:
198+
type: "object"
199+
properties:
200+
registry-client-auth:
201+
description: "Whether the engine supports client auth handling."
202+
type: "boolean"
203+
x-nullable: true
204+
example: true
205+
176206
Port:
177207
type: "object"
178208
description: "An open port on a container"
@@ -10156,6 +10186,90 @@ paths:
1015610186
schema:
1015710187
$ref: "#/definitions/ErrorResponse"
1015810188
tags: ["System"]
10189+
# Using a zero-width character here to define a separate /_ping endpoint to describe the
10190+
# /_ping?capabilities=1 API since otherwise Swagger won't allow us to define multiple
10191+
# responses for the same endpoint depending on query parameter.
10192+
# This is however supported by OpenAPI v3.
10193+
# See: https://github.com/OAI/OpenAPI-Specification/issues/146
10194+
# and https://github.com/OAI/OpenAPI-Specification/issues/182
10195+
/_ping​:
10196+
get:
10197+
summary: "/_ping?capabilities=1"
10198+
description: |
10199+
This is the same endpoint as `GET /_ping`, but describes the different
10200+
response when it is called with the `capabilities=1` query parameter.
10201+
10202+
In this case, the daemon instead responds with a `Content-Type` of
10203+
`application/json` and writes a json represenation of the engine's
10204+
capabilities in the response body.
10205+
operationId: "SystemPingCapabilities"
10206+
produces: ["application/json"]
10207+
parameters:
10208+
- name: "capabilities"
10209+
in: "query"
10210+
description: The capabilities API version being requested.
10211+
# marked as required since this is a separate endpoint in the swagger yaml.
10212+
required: true
10213+
type: "string"
10214+
enum: ["1"]
10215+
responses:
10216+
200:
10217+
description: "no error"
10218+
schema:
10219+
$ref: "#/definitions/Capabilities"
10220+
headers:
10221+
Api-Version:
10222+
type: "string"
10223+
description: "Max API Version the server supports"
10224+
Builder-Version:
10225+
type: "string"
10226+
description: |
10227+
Default version of docker image builder
10228+
10229+
The default on Linux is version "2" (BuildKit), but the daemon
10230+
can be configured to recommend version "1" (classic Builder).
10231+
Windows does not yet support BuildKit for native Windows images,
10232+
and uses "1" (classic builder) as a default.
10233+
10234+
This value is a recommendation as advertised by the daemon, and
10235+
it is up to the client to choose which builder to use.
10236+
default: "2"
10237+
Docker-Experimental:
10238+
type: "boolean"
10239+
description: "If the server is running with experimental mode enabled"
10240+
Swarm:
10241+
type: "string"
10242+
enum:
10243+
[
10244+
"inactive",
10245+
"pending",
10246+
"error",
10247+
"locked",
10248+
"active/worker",
10249+
"active/manager",
10250+
]
10251+
description: |
10252+
Contains information about Swarm status of the daemon,
10253+
and if the daemon is acting as a manager or worker node.
10254+
default: "inactive"
10255+
Cache-Control:
10256+
type: "string"
10257+
default: "no-cache, no-store, must-revalidate"
10258+
Pragma:
10259+
type: "string"
10260+
default: "no-cache"
10261+
500:
10262+
description: "server error"
10263+
schema:
10264+
$ref: "#/definitions/ErrorResponse"
10265+
headers:
10266+
Cache-Control:
10267+
type: "string"
10268+
default: "no-cache, no-store, must-revalidate"
10269+
Pragma:
10270+
type: "string"
10271+
default: "no-cache"
10272+
tags: ["System"]
1015910273
/commit:
1016010274
post:
1016110275
summary: "Create a new image from a container"

docs/api/version-history.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ keywords: "API, Docker, rcli, REST, documentation"
7171
`GET /debug/pprof/profile`, `GET /debug/pprof/symbol`, `GET /debug/pprof/trace`,
7272
`GET /debug/pprof/{name}`) are now also accessible through the versioned-API
7373
paths (`/v<API-version>/<endpoint>`).
74+
* `GET` `/_ping` endpoint now optionally supports a `capabilities` query parameter
75+
(e.g. `GET /_ping?capabilities=1`). If set, instead of the response body containing
76+
`OK`, the daemon responds with a JSON Content-Type instead of `text/plain`, and
77+
includes the engine capabilities in the response.
7478

7579
## v1.47 API changes
7680

0 commit comments

Comments
 (0)