Skip to content

Commit

Permalink
Corrected /_cat/indices response schema.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Jun 27, 2024
1 parent b2e5573 commit a7e5e34
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 6 deletions.
5 changes: 5 additions & 0 deletions spec/namespaces/cat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ components:
type: array
items:
$ref: '../schemas/cat.indices.yaml#/components/schemas/IndicesRecord'
application/yaml:
schema:
type: array
items:
$ref: '../schemas/cat.indices.yaml#/components/schemas/IndicesRecord'
cat.master@200:
description: ''
content:
Expand Down
8 changes: 4 additions & 4 deletions spec/schemas/cat.indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ components:
type: string
docs.count:
description: available docs
oneOf:
anyOf:
- type: string
- nullable: true
type: string
docs.deleted:
description: deleted docs
oneOf:
anyOf:
- type: string
- nullable: true
type: string
Expand All @@ -47,13 +47,13 @@ components:
type: string
store.size:
description: store size of primaries & replicas
oneOf:
anyOf:
- type: string
- nullable: true
type: string
pri.store.size:
description: store size of primaries
oneOf:
anyOf:
- type: string
- nullable: true
type: string
Expand Down
73 changes: 73 additions & 0 deletions tests/cat/indices.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cat/indices endpoints.
prologues:
- synopsis: Create an index named `books` with mappings and settings.
path: /{index}
method: PUT
parameters:
index: books
request_body:
payload: {}
epilogues:
- path: /books
method: DELETE
status: [200, 404]
chapters:
- synopsis: Cat with a default text response.
method: GET
path: /_cat/indices
response:
status: 200
content_type: text/plain
- synopsis: Cat with verbose output (v=true).
method: GET
path: /_cat/indices
parameters:
v: true
response:
status: 200
content_type: text/plain
- synopsis: Cat with headers (h=header1,header2).
method: GET
path: /_cat/indices
parameters:
h:
- health
- status
response:
status: 200
content_type: text/plain
- synopsis: Cat displaying all available headers (help=true).
method: GET
path: /_cat/indices
parameters:
help: true
response:
status: 200
content_type: text/plain
- synopsis: Cat with sorted results.
method: GET
path: /_cat/indices
parameters:
s:
- status
response:
status: 200
content_type: text/plain
- synopsis: Cat in different formats (format=json).
method: GET
path: /_cat/indices
parameters:
format: json
response:
status: 200
content_type: application/json
- synopsis: Cat in different formats (format=yaml).
method: GET
path: /_cat/indices
parameters:
format: yaml
response:
status: 200
content_type: application/yaml
3 changes: 1 addition & 2 deletions tools/src/tester/ChapterEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,12 @@ export default class ChapterEvaluator {
const schema = content?.schema
if (schema == null && content != null) return { result: Result.PASSED }
if (schema == null) return { result: Result.FAILED, message: `Schema for "${response.status}: ${response.content_type}" response not found in the spec.` }
console.log(this.#deserialize_payload(response.payload, content_type))
return this._schema_validator.validate(schema, this.#deserialize_payload(response.payload, content_type))
}

#deserialize_payload(payload: any, content_type: string): any {
if (payload === undefined) return undefined
switch(content_type) {
switch (content_type) {
case 'application/yaml': return YAML.parse(payload as string)
default: return payload
}
Expand Down

0 comments on commit a7e5e34

Please sign in to comment.