Skip to content

Fixed a badly formatted example #4851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions output/openapi/elasticsearch-openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions output/openapi/elasticsearch-serverless-openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions output/schema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ alternatives:
]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \"}'
\"$ELASTICSEARCH_URL/my-data-stream/_eql/search\""
- language: Java
code: |
code: >
client.eql().search(s -> s
.index("my-data-stream")
.query(" sequence by process.pid [ file where file.name == \"cmd.exe\" and process.pid != 2013 ][ process where stringContains(process.executable, \"regsvr32\") ] ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ alternatives:
library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n |
SORT year\\n | LIMIT 5\\n \",\"include_ccs_metadata\":true}' \"$ELASTICSEARCH_URL/_query\""
- language: Java
code: |
code: >
client.esql().query(q -> q
.includeCcsMetadata(true)
.query(" FROM library,remote-*:library | EVAL year = DATE_TRUNC(1 YEARS, release_date) | STATS MAX(page_count) BY year | SORT year | LIMIT 5 ")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
summary: Update index analysis
method_request: POST /my-index-000001/_close
description: To add an analyzer, you must close the index, define the analyzer, then reopen the index.
method_request: PUT /my-index-000001/_settings
description:
To add an analyzer, you must close the index (`POST /my-index-000001/_close`), define the analyzer, then reopen the
index (`POST /my-index-000001/_open`).
# type: request
value: "{

\ \"analysis\" : {

\ \"analyzer\":{

\ \"content\":{

\ \"type\":\"custom\",

\ \"tokenizer\":\"whitespace\"

\ }

\ }

\ }

value: |-
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really have a way to define examples that issue multiple requests, so I'm putting the 2nd and 3rd requests in the value key.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem like a valid OpenAPI example to me. Linters that check the request body example against the schema (we currently have those linting rules turned off) would fail due to those extra API requests in the value. I think we need to stick to one API request body per yaml file.

Copy link
Contributor Author

@miguelgrinberg miguelgrinberg Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current version of this example has two requests. And the method_request key in this example file is set to the "close index" endpoint, which does not take a body, and for that reason fails parsing in the request converter.

If we have to use one request per example, then maybe it is best to remove this example?

FYI, this is how the current two-request version looks in the official docs:

Screenshot 2025-07-10 at 10 40 44 AM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a commit eb281ad to put that info in the description instead. WDYT?

Copy link
Contributor Author

@miguelgrinberg miguelgrinberg Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good save a minor mistake in one of the URLs. Thanks!

Let me know if this looks good now.

{
"analysis": {
"analyzer": {
"content": {
"type": "custom",
"tokenizer": "whitespace"
}
}
}
}


POST /my-index-000001/_open"
alternatives:
- language: Python
code: |-
resp = client.indices.close(
index="my-index-000001",
)

resp1 = client.indices.open(
resp = client.indices.put_settings(
index="my-index-000001",
settings={
"analysis": {
"analyzer": {
"content": {
"type": "custom",
"tokenizer": "whitespace"
}
}
}
},
)
- language: JavaScript
code: |-
const response = await client.indices.close({
index: "my-index-000001",
});

const response1 = await client.indices.open({
const response = await client.indices.putSettings({
index: "my-index-000001",
settings: {
analysis: {
analyzer: {
content: {
type: "custom",
tokenizer: "whitespace",
},
},
},
},
});
- language: Ruby
code: |-
response = client.indices.close(
response = client.indices.put_settings(
index: "my-index-000001",
body: {
"analysis": {
Expand All @@ -58,13 +61,9 @@ alternatives:
}
}
)

response1 = client.indices.open(
index: "my-index-000001"
)
- language: PHP
code: |-
$resp = $client->indices()->close([
$resp = $client->indices()->putSettings([
"index" => "my-index-000001",
"body" => [
"analysis" => [
Expand All @@ -77,13 +76,8 @@ alternatives:
],
],
]);

$resp1 = $client->indices()->open([
"index" => "my-index-000001",
]);
- language: curl
code: >-
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d
'{"analysis":{"analyzer":{"content":{"type":"custom","tokenizer":"whitespace"}}}}' "$ELASTICSEARCH_URL/my-index-000001/_close"

curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/my-index-000001/_open"
code:
'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d
''{"analysis":{"analyzer":{"content":{"type":"custom","tokenizer":"whitespace"}}}}''
"$ELASTICSEARCH_URL/my-index-000001/_settings"'
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ alternatives:
''{"docs":[{"text":"The fool doth think he is wise, but the wise man knows himself to be a fool."}]}''
"$ELASTICSEARCH_URL/_ml/trained_models/lang_ident_model_1/_infer"'
- language: Java
code: |
code: >
client.ml().inferTrainedModel(i -> i
.docs(Map.of("text", JsonData.fromJson("\"The fool doth think he is wise, but the wise man knows himself to be a fool.\"")))
.modelId("lang_ident_model_1")
Expand Down