From 1ffa4254ed434309aa4e79e2e391c020ae1fe90c Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 10 Sep 2025 15:55:49 +0400 Subject: [PATCH] Fix optional bodies (#5271) * Fix optional bodies * Mark snapshot.create/snapshot.restore bodies as optional too (cherry picked from commit 3348b2fe5e2645db2d9e2bd5b7251f1130c3e005) --- output/openapi/elasticsearch-openapi.json | 12 ++++++++++-- .../openapi/elasticsearch-serverless-openapi.json | 9 +++++++++ output/schema/schema.json | 14 +++++++++++--- output/typescript/types.ts | 1 + .../mtermvectors/MultiTermVectorsRequest.ts | 2 +- .../_global/search_mvt/SearchMvtRequest.ts | 2 +- .../_global/termvectors/TermVectorsRequest.ts | 2 +- .../submit/AsyncSearchSubmitRequest.ts | 2 +- .../ccr/resume_follow/ResumeFollowIndexRequest.ts | 2 +- specification/ilm/migrate_to_data_tiers/Request.ts | 2 +- .../create_from/MigrateCreateFromRequest.ts | 2 +- .../indices/put_alias/IndicesPutAliasRequest.ts | 2 +- .../IndicesSimulateIndexTemplateRequest.ts | 3 +++ .../IndicesSimulateTemplateRequest.ts | 2 +- specification/ml/close_job/MlCloseJobRequest.ts | 2 +- .../MlExplainDataFrameAnalyticsRequest.ts | 2 +- specification/ml/forecast/MlForecastJobRequest.ts | 2 +- specification/ml/open_job/MlOpenJobRequest.ts | 2 +- .../MlPreviewDataFrameAnalyticsRequest.ts | 2 +- .../preview_datafeed/MlPreviewDatafeedRequest.ts | 2 +- .../ml/put_calendar/MlPutCalendarRequest.ts | 2 +- .../MlStartTrainedModelDeploymentRequest.ts | 2 +- .../ml/stop_datafeed/MlStopDatafeedRequest.ts | 2 +- .../MlUpdateTrainedModelDeploymentRequest.ts | 2 +- .../ReloadSecureSettingsRequest.ts | 2 +- .../SearchApplicationsRenderQueryRequest.ts | 2 +- .../search/SearchApplicationsSearchRequest.ts | 2 +- .../security/query_api_keys/QueryApiKeysRequest.ts | 2 +- .../security/query_role/QueryRolesRequest.ts | 2 +- .../query_user/SecurityQueryUserRequest.ts | 2 +- .../security/suggest_user_profiles/Request.ts | 2 +- specification/security/update_api_key/Request.ts | 2 +- .../snapshot/create/SnapshotCreateRequest.ts | 2 +- .../snapshot/restore/SnapshotRestoreRequest.ts | 2 +- .../preview_transform/PreviewTransformRequest.ts | 2 +- .../execute_watch/WatcherExecuteWatchRequest.ts | 2 +- .../query_watches/WatcherQueryWatchesRequest.ts | 2 +- 37 files changed, 66 insertions(+), 37 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index e62a6c538e..bf732bfd0e 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -19855,6 +19855,15 @@ "style": "form" } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/indices._types.IndexTemplate" + } + } + } + }, "responses": { "200": { "description": "", @@ -146288,8 +146297,7 @@ "$ref": "#/components/schemas/indices.create_from.CreateFrom" } } - }, - "required": true + } }, "indices.put_alias": { "content": { diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index eb649498ca..fa27df6a8d 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -10786,6 +10786,15 @@ "style": "form" } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/indices._types.IndexTemplate" + } + } + } + }, "responses": { "200": { "description": "", diff --git a/output/schema/schema.json b/output/schema/schema.json index b5993be584..695b501201 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -6934,7 +6934,7 @@ "name": "Request", "namespace": "indices.create_from" }, - "requestBodyRequired": true, + "requestBodyRequired": false, "requestMediaType": [ "application/json" ], @@ -165962,7 +165962,15 @@ "CommonQueryParameters" ], "body": { - "kind": "no_body" + "kind": "value", + "codegenName": "index_template", + "value": { + "kind": "instance_of", + "type": { + "name": "IndexTemplate", + "namespace": "indices._types" + } + } }, "description": "Simulate an index.\nGet the index configuration that would be applied to the specified index from an existing index template.", "examples": { @@ -166083,7 +166091,7 @@ } } ], - "specLocation": "indices/simulate_index_template/IndicesSimulateIndexTemplateRequest.ts#L24-L67" + "specLocation": "indices/simulate_index_template/IndicesSimulateIndexTemplateRequest.ts#L25-L70" }, { "kind": "response", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 2022396adc..4e1384d17e 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -13445,6 +13445,7 @@ export interface IndicesSimulateIndexTemplateRequest extends RequestBase { cause?: string master_timeout?: Duration include_defaults?: boolean + body?: IndicesIndexTemplate } export interface IndicesSimulateIndexTemplateResponse { diff --git a/specification/_global/mtermvectors/MultiTermVectorsRequest.ts b/specification/_global/mtermvectors/MultiTermVectorsRequest.ts index b0b944b3db..ae979954b8 100644 --- a/specification/_global/mtermvectors/MultiTermVectorsRequest.ts +++ b/specification/_global/mtermvectors/MultiTermVectorsRequest.ts @@ -121,7 +121,7 @@ export interface Request extends RequestBase { */ version_type?: VersionType } - body: { + body?: { /** * An array of existing or artificial documents. */ diff --git a/specification/_global/search_mvt/SearchMvtRequest.ts b/specification/_global/search_mvt/SearchMvtRequest.ts index a651907389..d484884d9a 100644 --- a/specification/_global/search_mvt/SearchMvtRequest.ts +++ b/specification/_global/search_mvt/SearchMvtRequest.ts @@ -221,7 +221,7 @@ export interface Request extends RequestBase { */ with_labels?: boolean } - body: { + body?: { /** * Sub-aggregations for the geotile_grid. * diff --git a/specification/_global/termvectors/TermVectorsRequest.ts b/specification/_global/termvectors/TermVectorsRequest.ts index de0802c948..1784dc193e 100644 --- a/specification/_global/termvectors/TermVectorsRequest.ts +++ b/specification/_global/termvectors/TermVectorsRequest.ts @@ -167,7 +167,7 @@ export interface Request extends RequestBase { */ version_type?: VersionType } - body: { + body?: { /** * An artificial document (a document not present in the index) for which you want to retrieve term vectors. */ diff --git a/specification/async_search/submit/AsyncSearchSubmitRequest.ts b/specification/async_search/submit/AsyncSearchSubmitRequest.ts index 1279697dac..b42d17c9f7 100644 --- a/specification/async_search/submit/AsyncSearchSubmitRequest.ts +++ b/specification/async_search/submit/AsyncSearchSubmitRequest.ts @@ -158,7 +158,7 @@ export interface Request extends RequestBase { from?: integer sort?: string | string[] } - body: { + body?: { /** @aliases aggs */ aggregations?: Dictionary collapse?: FieldCollapse diff --git a/specification/ccr/resume_follow/ResumeFollowIndexRequest.ts b/specification/ccr/resume_follow/ResumeFollowIndexRequest.ts index 33db98212d..cc8c196c6c 100644 --- a/specification/ccr/resume_follow/ResumeFollowIndexRequest.ts +++ b/specification/ccr/resume_follow/ResumeFollowIndexRequest.ts @@ -50,7 +50,7 @@ export interface Request extends RequestBase { */ master_timeout?: Duration } - body: { + body?: { max_outstanding_read_requests?: long max_outstanding_write_requests?: long max_read_request_operation_count?: long diff --git a/specification/ilm/migrate_to_data_tiers/Request.ts b/specification/ilm/migrate_to_data_tiers/Request.ts index bbcbd2333a..0b6fa2e189 100644 --- a/specification/ilm/migrate_to_data_tiers/Request.ts +++ b/specification/ilm/migrate_to_data_tiers/Request.ts @@ -62,7 +62,7 @@ export interface Request extends RequestBase { */ master_timeout?: Duration } - body: { + body?: { legacy_template_to_delete?: string node_attribute?: string } diff --git a/specification/indices/create_from/MigrateCreateFromRequest.ts b/specification/indices/create_from/MigrateCreateFromRequest.ts index 491c6c5e72..1cf4700576 100644 --- a/specification/indices/create_from/MigrateCreateFromRequest.ts +++ b/specification/indices/create_from/MigrateCreateFromRequest.ts @@ -40,7 +40,7 @@ export interface Request extends RequestBase { dest: IndexName } /** @codegen_name create_from */ - body: CreateFrom + body?: CreateFrom } export class CreateFrom { diff --git a/specification/indices/put_alias/IndicesPutAliasRequest.ts b/specification/indices/put_alias/IndicesPutAliasRequest.ts index ffd0593739..efefc114ae 100644 --- a/specification/indices/put_alias/IndicesPutAliasRequest.ts +++ b/specification/indices/put_alias/IndicesPutAliasRequest.ts @@ -70,7 +70,7 @@ export interface Request extends RequestBase { */ timeout?: Duration } - body: { + body?: { /** * Query used to limit documents the alias can access. */ diff --git a/specification/indices/simulate_index_template/IndicesSimulateIndexTemplateRequest.ts b/specification/indices/simulate_index_template/IndicesSimulateIndexTemplateRequest.ts index e2f13464a8..5b3e340276 100644 --- a/specification/indices/simulate_index_template/IndicesSimulateIndexTemplateRequest.ts +++ b/specification/indices/simulate_index_template/IndicesSimulateIndexTemplateRequest.ts @@ -20,6 +20,7 @@ import { RequestBase } from '@_types/Base' import { Name } from '@_types/common' import { Duration } from '@_types/Time' +import { IndexTemplate } from '@indices/_types/IndexTemplate' /** * Simulate an index. @@ -64,4 +65,6 @@ export interface Request extends RequestBase { */ include_defaults?: boolean } + /** @codegen_name index_template */ + body?: IndexTemplate } diff --git a/specification/indices/simulate_template/IndicesSimulateTemplateRequest.ts b/specification/indices/simulate_template/IndicesSimulateTemplateRequest.ts index ca1f3c9460..3433374c17 100644 --- a/specification/indices/simulate_template/IndicesSimulateTemplateRequest.ts +++ b/specification/indices/simulate_template/IndicesSimulateTemplateRequest.ts @@ -74,7 +74,7 @@ export interface Request extends RequestBase { */ include_defaults?: boolean } - body: { + body?: { /** * This setting overrides the value of the `action.auto_create_index` cluster setting. * If set to `true` in a template, then indices can be automatically created using that template even if auto-creation of indices is disabled via `actions.auto_create_index`. diff --git a/specification/ml/close_job/MlCloseJobRequest.ts b/specification/ml/close_job/MlCloseJobRequest.ts index 79e174aba4..8b3b14006c 100644 --- a/specification/ml/close_job/MlCloseJobRequest.ts +++ b/specification/ml/close_job/MlCloseJobRequest.ts @@ -66,7 +66,7 @@ export interface Request extends RequestBase { * @server_default 30m */ timeout?: Duration } - body: { + body?: { /** * Refer to the description for the `allow_no_match` query parameter. * @server_default true diff --git a/specification/ml/explain_data_frame_analytics/MlExplainDataFrameAnalyticsRequest.ts b/specification/ml/explain_data_frame_analytics/MlExplainDataFrameAnalyticsRequest.ts index b84b6940fd..96e764ce97 100644 --- a/specification/ml/explain_data_frame_analytics/MlExplainDataFrameAnalyticsRequest.ts +++ b/specification/ml/explain_data_frame_analytics/MlExplainDataFrameAnalyticsRequest.ts @@ -62,7 +62,7 @@ export interface Request extends RequestBase { */ id?: Id } - body: { + body?: { /** * The configuration of how to source the analysis data. It requires an * index. Optionally, query and _source may be specified. diff --git a/specification/ml/forecast/MlForecastJobRequest.ts b/specification/ml/forecast/MlForecastJobRequest.ts index 35a4e1464a..9133f93330 100644 --- a/specification/ml/forecast/MlForecastJobRequest.ts +++ b/specification/ml/forecast/MlForecastJobRequest.ts @@ -75,7 +75,7 @@ export interface Request extends RequestBase { */ max_model_memory?: string } - body: { + body?: { /** * Refer to the description for the `duration` query parameter. * @server_default 1d diff --git a/specification/ml/open_job/MlOpenJobRequest.ts b/specification/ml/open_job/MlOpenJobRequest.ts index 8fb149db73..c0eb92b59c 100644 --- a/specification/ml/open_job/MlOpenJobRequest.ts +++ b/specification/ml/open_job/MlOpenJobRequest.ts @@ -57,7 +57,7 @@ export interface Request extends RequestBase { */ timeout?: Duration } - body: { + body?: { /** * Refer to the description for the `timeout` query parameter. * @server_default 30m diff --git a/specification/ml/preview_data_frame_analytics/MlPreviewDataFrameAnalyticsRequest.ts b/specification/ml/preview_data_frame_analytics/MlPreviewDataFrameAnalyticsRequest.ts index 9c39b1d06d..bc1c0a2ea2 100644 --- a/specification/ml/preview_data_frame_analytics/MlPreviewDataFrameAnalyticsRequest.ts +++ b/specification/ml/preview_data_frame_analytics/MlPreviewDataFrameAnalyticsRequest.ts @@ -48,7 +48,7 @@ export interface Request extends RequestBase { */ id?: Id } - body: { + body?: { /** * A data frame analytics config as described in create data frame analytics * jobs. Note that `id` and `dest` don’t need to be provided in the context of diff --git a/specification/ml/preview_datafeed/MlPreviewDatafeedRequest.ts b/specification/ml/preview_datafeed/MlPreviewDatafeedRequest.ts index 5e6de862cc..8112cf536c 100644 --- a/specification/ml/preview_datafeed/MlPreviewDatafeedRequest.ts +++ b/specification/ml/preview_datafeed/MlPreviewDatafeedRequest.ts @@ -65,7 +65,7 @@ export interface Request extends RequestBase { start?: DateTime end?: DateTime } - body: { + body?: { /** * The datafeed definition to preview. */ diff --git a/specification/ml/put_calendar/MlPutCalendarRequest.ts b/specification/ml/put_calendar/MlPutCalendarRequest.ts index 961493f083..4c01210a91 100644 --- a/specification/ml/put_calendar/MlPutCalendarRequest.ts +++ b/specification/ml/put_calendar/MlPutCalendarRequest.ts @@ -40,7 +40,7 @@ export interface Request extends RequestBase { /** A string that uniquely identifies a calendar. */ calendar_id: Id } - body: { + body?: { /** * An array of anomaly detection job identifiers. */ diff --git a/specification/ml/start_trained_model_deployment/MlStartTrainedModelDeploymentRequest.ts b/specification/ml/start_trained_model_deployment/MlStartTrainedModelDeploymentRequest.ts index 0ecb580896..c592b880eb 100644 --- a/specification/ml/start_trained_model_deployment/MlStartTrainedModelDeploymentRequest.ts +++ b/specification/ml/start_trained_model_deployment/MlStartTrainedModelDeploymentRequest.ts @@ -100,7 +100,7 @@ export interface Request extends RequestBase { */ wait_for?: DeploymentAllocationState } - body: { + body?: { /** * Adaptive allocations configuration. When enabled, the number of allocations * is set based on the current load. diff --git a/specification/ml/stop_datafeed/MlStopDatafeedRequest.ts b/specification/ml/stop_datafeed/MlStopDatafeedRequest.ts index 078869144c..e474f3bd94 100644 --- a/specification/ml/stop_datafeed/MlStopDatafeedRequest.ts +++ b/specification/ml/stop_datafeed/MlStopDatafeedRequest.ts @@ -69,7 +69,7 @@ export interface Request extends RequestBase { * @server_default 20s */ timeout?: Duration } - body: { + body?: { /** * Refer to the description for the `allow_no_match` query parameter. * @server_default true */ diff --git a/specification/ml/update_trained_model_deployment/MlUpdateTrainedModelDeploymentRequest.ts b/specification/ml/update_trained_model_deployment/MlUpdateTrainedModelDeploymentRequest.ts index cc16fbef0f..f6d4291811 100644 --- a/specification/ml/update_trained_model_deployment/MlUpdateTrainedModelDeploymentRequest.ts +++ b/specification/ml/update_trained_model_deployment/MlUpdateTrainedModelDeploymentRequest.ts @@ -56,7 +56,7 @@ export interface Request extends RequestBase { */ number_of_allocations?: integer } - body: { + body?: { /** * The number of model allocations on each node where the model is deployed. * All allocations on a node share the same copy of the model in memory but use diff --git a/specification/nodes/reload_secure_settings/ReloadSecureSettingsRequest.ts b/specification/nodes/reload_secure_settings/ReloadSecureSettingsRequest.ts index 72bc692cba..abcd7e3856 100644 --- a/specification/nodes/reload_secure_settings/ReloadSecureSettingsRequest.ts +++ b/specification/nodes/reload_secure_settings/ReloadSecureSettingsRequest.ts @@ -61,7 +61,7 @@ export interface Request extends RequestBase { */ timeout?: Duration } - body: { + body?: { /** * The password for the Elasticsearch keystore. */ diff --git a/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts b/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts index 7c1d250f35..764ed292c0 100644 --- a/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts +++ b/specification/search_application/render_query/SearchApplicationsRenderQueryRequest.ts @@ -48,7 +48,7 @@ export interface Request extends RequestBase { /** * Contains parameters for a search application. */ - body: { + body?: { params?: Dictionary } } diff --git a/specification/search_application/search/SearchApplicationsSearchRequest.ts b/specification/search_application/search/SearchApplicationsSearchRequest.ts index 68f22a6238..55e8d0e21c 100644 --- a/specification/search_application/search/SearchApplicationsSearchRequest.ts +++ b/specification/search_application/search/SearchApplicationsSearchRequest.ts @@ -52,7 +52,7 @@ export interface Request extends RequestBase { */ typed_keys?: boolean } - body: { + body?: { /** * Query parameters specific to this request, which will override any defaults specified in the template. */ diff --git a/specification/security/query_api_keys/QueryApiKeysRequest.ts b/specification/security/query_api_keys/QueryApiKeysRequest.ts index a01c9f98bf..91ccda6a12 100644 --- a/specification/security/query_api_keys/QueryApiKeysRequest.ts +++ b/specification/security/query_api_keys/QueryApiKeysRequest.ts @@ -72,7 +72,7 @@ export interface Request extends RequestBase { */ typed_keys?: boolean } - body: { + body?: { /** * Any aggregations to run over the corpus of returned API keys. * Aggregations and queries work together. Aggregations are computed only on the API keys that match the query. diff --git a/specification/security/query_role/QueryRolesRequest.ts b/specification/security/query_role/QueryRolesRequest.ts index 23c8258b27..660433cd17 100644 --- a/specification/security/query_role/QueryRolesRequest.ts +++ b/specification/security/query_role/QueryRolesRequest.ts @@ -43,7 +43,7 @@ export interface Request extends RequestBase { methods: ['GET', 'POST'] } ] - body: { + body?: { /** * A query to filter which roles to return. * If the query parameter is missing, it is equivalent to a `match_all` query. diff --git a/specification/security/query_user/SecurityQueryUserRequest.ts b/specification/security/query_user/SecurityQueryUserRequest.ts index 34a107edba..06e4bd591b 100644 --- a/specification/security/query_user/SecurityQueryUserRequest.ts +++ b/specification/security/query_user/SecurityQueryUserRequest.ts @@ -43,7 +43,7 @@ export interface Request extends RequestBase { methods: ['GET', 'POST'] } ] - body: { + body?: { /** * A query to filter which users to return. * If the query parameter is missing, it is equivalent to a `match_all` query. diff --git a/specification/security/suggest_user_profiles/Request.ts b/specification/security/suggest_user_profiles/Request.ts index e3d8ea6d50..c09034fea5 100644 --- a/specification/security/suggest_user_profiles/Request.ts +++ b/specification/security/suggest_user_profiles/Request.ts @@ -52,7 +52,7 @@ export interface Request extends RequestBase { */ data?: string | string[] } - body: { + body?: { /** * A query string used to match name-related fields in user profile documents. * Name-related fields are the user's `username`, `full_name`, and `email`. diff --git a/specification/security/update_api_key/Request.ts b/specification/security/update_api_key/Request.ts index 89aa28739d..9aa163dbd0 100644 --- a/specification/security/update_api_key/Request.ts +++ b/specification/security/update_api_key/Request.ts @@ -63,7 +63,7 @@ export interface Request extends RequestBase { */ id: Id } - body: { + body?: { /** * The role descriptors to assign to this API key. * The API key's effective permissions are an intersection of its assigned privileges and the point in time snapshot of permissions of the owner user. diff --git a/specification/snapshot/create/SnapshotCreateRequest.ts b/specification/snapshot/create/SnapshotCreateRequest.ts index 4e449d47db..89716422c0 100644 --- a/specification/snapshot/create/SnapshotCreateRequest.ts +++ b/specification/snapshot/create/SnapshotCreateRequest.ts @@ -64,7 +64,7 @@ export interface Request extends RequestBase { */ wait_for_completion?: boolean } - body: { + body?: { /** * Determines how wildcard patterns in the `indices` parameter match data streams and indices. * It supports comma-separated values such as `open,hidden`. diff --git a/specification/snapshot/restore/SnapshotRestoreRequest.ts b/specification/snapshot/restore/SnapshotRestoreRequest.ts index 2b5d1ff29d..1fd52c82ed 100644 --- a/specification/snapshot/restore/SnapshotRestoreRequest.ts +++ b/specification/snapshot/restore/SnapshotRestoreRequest.ts @@ -83,7 +83,7 @@ export interface Request extends RequestBase { */ wait_for_completion?: boolean } - body: { + body?: { /** * The feature states to restore. * If `include_global_state` is `true`, the request restores all feature states in the snapshot by default. diff --git a/specification/transform/preview_transform/PreviewTransformRequest.ts b/specification/transform/preview_transform/PreviewTransformRequest.ts index 18e7ee11b2..0de93ec7f8 100644 --- a/specification/transform/preview_transform/PreviewTransformRequest.ts +++ b/specification/transform/preview_transform/PreviewTransformRequest.ts @@ -70,7 +70,7 @@ export interface Request extends RequestBase { */ timeout?: Duration } - body: { + body?: { /** * The destination for the transform. */ diff --git a/specification/watcher/execute_watch/WatcherExecuteWatchRequest.ts b/specification/watcher/execute_watch/WatcherExecuteWatchRequest.ts index 6b26096be8..3aa46a54d7 100644 --- a/specification/watcher/execute_watch/WatcherExecuteWatchRequest.ts +++ b/specification/watcher/execute_watch/WatcherExecuteWatchRequest.ts @@ -71,7 +71,7 @@ export interface Request extends RequestBase { */ debug?: boolean } - body: { + body?: { /** * Determines how to handle the watch actions as part of the watch execution. */ diff --git a/specification/watcher/query_watches/WatcherQueryWatchesRequest.ts b/specification/watcher/query_watches/WatcherQueryWatchesRequest.ts index 43953eb97b..473a78a26c 100644 --- a/specification/watcher/query_watches/WatcherQueryWatchesRequest.ts +++ b/specification/watcher/query_watches/WatcherQueryWatchesRequest.ts @@ -39,7 +39,7 @@ export interface Request extends RequestBase { methods: ['GET', 'POST'] } ] - body: { + body?: { /** * The offset from the first result to fetch. * It must be non-negative.