mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
use mime-type application/jsonl to align with openapi 3.2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
b8093b76fb
commit
aef5d996ce
@@ -17,6 +17,8 @@ keywords: "API, Docker, rcli, REST, documentation"
|
|||||||
|
|
||||||
* `GET /info` now includes an `NRI` field. If the Node Resource Interface (NRI)
|
* `GET /info` now includes an `NRI` field. If the Node Resource Interface (NRI)
|
||||||
is enabled, this field contains information describing it.
|
is enabled, this field contains information describing it.
|
||||||
|
* `GET /events` now also supports [`application/jsonl`](https://jsonlines.org/)
|
||||||
|
when negotiating content-type.
|
||||||
* Deprecated: The `POST /grpc` and `POST /session` endpoints are deprecated and
|
* Deprecated: The `POST /grpc` and `POST /session` endpoints are deprecated and
|
||||||
will be removed in a future version.
|
will be removed in a future version.
|
||||||
|
|
||||||
|
|||||||
@@ -10463,6 +10463,7 @@ paths:
|
|||||||
|
|
||||||
operationId: "SystemEvents"
|
operationId: "SystemEvents"
|
||||||
produces:
|
produces:
|
||||||
|
- "application/jsonl"
|
||||||
- "application/x-ndjson"
|
- "application/x-ndjson"
|
||||||
- "application/json-seq"
|
- "application/json-seq"
|
||||||
responses:
|
responses:
|
||||||
|
|||||||
@@ -10,9 +10,12 @@ const (
|
|||||||
// MediaTypeJSON is the MIME-Type for JSON objects.
|
// MediaTypeJSON is the MIME-Type for JSON objects.
|
||||||
MediaTypeJSON = "application/json"
|
MediaTypeJSON = "application/json"
|
||||||
|
|
||||||
// MediaTypeNDJSON is the MIME-Type for Newline Delimited JSON objects streams.
|
// MediaTypeNDJSON is the MIME-Type for Newline Delimited JSON objects streams (https://github.com/ndjson/ndjson-spec).
|
||||||
MediaTypeNDJSON = "application/x-ndjson"
|
MediaTypeNDJSON = "application/x-ndjson"
|
||||||
|
|
||||||
|
// MediaTypeJSONLines is the MIME-Type for JSONLines objects streams (https://jsonlines.org/).
|
||||||
|
MediaTypeJSONLines = "application/jsonl"
|
||||||
|
|
||||||
// MediaTypeJSONSequence is the MIME-Type for JSON Text Sequences (RFC7464).
|
// MediaTypeJSONSequence is the MIME-Type for JSON Text Sequences (RFC7464).
|
||||||
MediaTypeJSONSequence = "application/json-seq"
|
MediaTypeJSONSequence = "application/json-seq"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func NewJSONStreamDecoder(r io.Reader, contentType string) DecoderFn {
|
|||||||
switch contentType {
|
switch contentType {
|
||||||
case types.MediaTypeJSONSequence:
|
case types.MediaTypeJSONSequence:
|
||||||
return json.NewDecoder(NewRSFilterReader(r)).Decode
|
return json.NewDecoder(NewRSFilterReader(r)).Decode
|
||||||
case types.MediaTypeJSON, types.MediaTypeNDJSON:
|
case types.MediaTypeJSON, types.MediaTypeNDJSON, types.MediaTypeJSONLines:
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
return json.NewDecoder(r).Decode
|
return json.NewDecoder(r).Decode
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (cli *Client) Events(ctx context.Context, options EventsListOptions) Events
|
|||||||
|
|
||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
headers.Add("Accept", types.MediaTypeJSONSequence)
|
headers.Add("Accept", types.MediaTypeJSONSequence)
|
||||||
|
headers.Add("Accept", types.MediaTypeJSONLines)
|
||||||
headers.Add("Accept", types.MediaTypeNDJSON)
|
headers.Add("Accept", types.MediaTypeNDJSON)
|
||||||
resp, err := cli.get(ctx, "/events", query, headers)
|
resp, err := cli.get(ctx, "/events", query, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func NewJSONStreamEncoder(w io.Writer, contentType string) EncoderFn {
|
|||||||
json: jsonEncoder,
|
json: jsonEncoder,
|
||||||
}
|
}
|
||||||
return jseq.Encode
|
return jseq.Encode
|
||||||
case types.MediaTypeNDJSON, types.MediaTypeJSON:
|
case types.MediaTypeNDJSON, types.MediaTypeJSON, types.MediaTypeJSONLines:
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
return jsonEncoder.Encode
|
return jsonEncoder.Encode
|
||||||
|
|||||||
@@ -311,6 +311,7 @@ func (s *systemRouter) getEvents(ctx context.Context, w http.ResponseWriter, r *
|
|||||||
}
|
}
|
||||||
|
|
||||||
contentType := httputil.NegotiateContentType(r, []string{
|
contentType := httputil.NegotiateContentType(r, []string{
|
||||||
|
types.MediaTypeJSONLines,
|
||||||
types.MediaTypeNDJSON,
|
types.MediaTypeNDJSON,
|
||||||
types.MediaTypeJSONSequence,
|
types.MediaTypeJSONSequence,
|
||||||
}, types.MediaTypeJSON) // output isn't actually JSON but API used to this content-type
|
}, types.MediaTypeJSON) // output isn't actually JSON but API used to this content-type
|
||||||
|
|||||||
5
vendor/github.com/moby/moby/api/types/types.go
generated
vendored
5
vendor/github.com/moby/moby/api/types/types.go
generated
vendored
@@ -10,9 +10,12 @@ const (
|
|||||||
// MediaTypeJSON is the MIME-Type for JSON objects.
|
// MediaTypeJSON is the MIME-Type for JSON objects.
|
||||||
MediaTypeJSON = "application/json"
|
MediaTypeJSON = "application/json"
|
||||||
|
|
||||||
// MediaTypeNDJSON is the MIME-Type for Newline Delimited JSON objects streams.
|
// MediaTypeNDJSON is the MIME-Type for Newline Delimited JSON objects streams (https://github.com/ndjson/ndjson-spec).
|
||||||
MediaTypeNDJSON = "application/x-ndjson"
|
MediaTypeNDJSON = "application/x-ndjson"
|
||||||
|
|
||||||
|
// MediaTypeJSONLines is the MIME-Type for JSONLines objects streams (https://jsonlines.org/).
|
||||||
|
MediaTypeJSONLines = "application/jsonl"
|
||||||
|
|
||||||
// MediaTypeJSONSequence is the MIME-Type for JSON Text Sequences (RFC7464).
|
// MediaTypeJSONSequence is the MIME-Type for JSON Text Sequences (RFC7464).
|
||||||
MediaTypeJSONSequence = "application/json-seq"
|
MediaTypeJSONSequence = "application/json-seq"
|
||||||
)
|
)
|
||||||
|
|||||||
2
vendor/github.com/moby/moby/client/internal/json-stream.go
generated
vendored
2
vendor/github.com/moby/moby/client/internal/json-stream.go
generated
vendored
@@ -17,7 +17,7 @@ func NewJSONStreamDecoder(r io.Reader, contentType string) DecoderFn {
|
|||||||
switch contentType {
|
switch contentType {
|
||||||
case types.MediaTypeJSONSequence:
|
case types.MediaTypeJSONSequence:
|
||||||
return json.NewDecoder(NewRSFilterReader(r)).Decode
|
return json.NewDecoder(NewRSFilterReader(r)).Decode
|
||||||
case types.MediaTypeJSON, types.MediaTypeNDJSON:
|
case types.MediaTypeJSON, types.MediaTypeNDJSON, types.MediaTypeJSONLines:
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
return json.NewDecoder(r).Decode
|
return json.NewDecoder(r).Decode
|
||||||
|
|||||||
1
vendor/github.com/moby/moby/client/system_events.go
generated
vendored
1
vendor/github.com/moby/moby/client/system_events.go
generated
vendored
@@ -46,6 +46,7 @@ func (cli *Client) Events(ctx context.Context, options EventsListOptions) Events
|
|||||||
|
|
||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
headers.Add("Accept", types.MediaTypeJSONSequence)
|
headers.Add("Accept", types.MediaTypeJSONSequence)
|
||||||
|
headers.Add("Accept", types.MediaTypeJSONLines)
|
||||||
headers.Add("Accept", types.MediaTypeNDJSON)
|
headers.Add("Accept", types.MediaTypeNDJSON)
|
||||||
resp, err := cli.get(ctx, "/events", query, headers)
|
resp, err := cli.get(ctx, "/events", query, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user