From 539f4894961c7fc1e626682fb238dee880309be1 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Tue, 18 Mar 2025 08:11:21 +0100 Subject: [PATCH] Emit `codegen_name` for response value bodies (#3953) * Emit `codegen_name` for response value bodies * Run make contrib --------- Co-authored-by: Quentin Pradet (cherry picked from commit 331583c54ed24eb2a33f853eec97776e4fdb1590) # Conflicts: # output/schema/schema-serverless.json --- compiler/src/model/build-model.ts | 13 ++++++- output/openapi/elasticsearch-openapi.json | 4 +-- .../elasticsearch-serverless-openapi.json | 4 +-- output/schema/schema-serverless.json | 15 ++++++-- output/schema/schema.json | 35 +++++++++++++++++-- 5 files changed, 62 insertions(+), 9 deletions(-) diff --git a/compiler/src/model/build-model.ts b/compiler/src/model/build-model.ts index 96bb7f511b..400a0f008b 100644 --- a/compiler/src/model/build-model.ts +++ b/compiler/src/model/build-model.ts @@ -383,7 +383,18 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int if (property.valueOf.kind === 'instance_of' && property.valueOf.type.name === 'Void') { type.body = { kind: 'no_body' } } else { - type.body = { kind: 'value', value: property.valueOf } + const tags = parseJsDocTags((member as PropertySignature).getJsDocs()) + // TODO: Enable this after adding the missing codegen names. + // assert( + // member as Node, + // tags.codegen_name != null, + // 'You should configure a body @codegen_name' + // ) + type.body = { + kind: 'value', + value: property.valueOf, + codegenName: tags.codegen_name + } } } else { type.body = { kind: 'properties', properties: property.properties } diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 7fa23b4615..86e25d8963 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -22270,7 +22270,7 @@ "MlEvaluateDataFrameRequestExample4": { "summary": "Regression example 1", "description": "Run `POST _ml/data_frame/_evaluate` to evaluate the testing error of a regression job for an annotated index. The term query in the body limits evaluation to be performed on the test split only. The `actual_field` contains the ground truth for house prices. The `predicted_field` contains the house price calculated by the regression analysis.\n", - "value": "{\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n }\n}" + "value": "{\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n }\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n}" }, "MlEvaluateDataFrameRequestExample5": { "summary": "Regression example 2", @@ -113780,7 +113780,7 @@ "MultiTermVectorsRequestExample2": { "summary": "Simplified syntax", "description": "Run `POST /my-index-000001/_mtermvectors`. If all requested documents are in same index and the parameters are the same, you can use a simplified syntax.\n", - "value": "{\n \"ids\": [ \"1\", \"2\" ],\n \"parameters\": {\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n }\n}" + "value": "{\n \"ids\": [ \"1\", \"2\" ],\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n}" }, "MultiTermVectorsRequestExample3": { "summary": "Artificial documents", diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 4d2498dd2a..c99c282e5a 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -12807,7 +12807,7 @@ "MlEvaluateDataFrameRequestExample4": { "summary": "Regression example 1", "description": "Run `POST _ml/data_frame/_evaluate` to evaluate the testing error of a regression job for an annotated index. The term query in the body limits evaluation to be performed on the test split only. The `actual_field` contains the ground truth for house prices. The `predicted_field` contains the house price calculated by the regression analysis.\n", - "value": "{\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n }\n}" + "value": "{\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n }\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n}" }, "MlEvaluateDataFrameRequestExample5": { "summary": "Regression example 2", @@ -66588,7 +66588,7 @@ "MultiTermVectorsRequestExample2": { "summary": "Simplified syntax", "description": "Run `POST /my-index-000001/_mtermvectors`. If all requested documents are in same index and the parameters are the same, you can use a simplified syntax.\n", - "value": "{\n \"ids\": [ \"1\", \"2\" ],\n \"parameters\": {\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n }\n}" + "value": "{\n \"ids\": [ \"1\", \"2\" ],\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n}" }, "MultiTermVectorsRequestExample3": { "summary": "Artificial documents", diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index b351cae3bf..88f98b5b21 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -19451,6 +19451,7 @@ }, { "body": { + "codegenName": "data", "kind": "value", "value": { "kind": "instance_of", @@ -20954,6 +20955,7 @@ }, { "body": { + "codegenName": "source", "kind": "value", "value": { "kind": "instance_of", @@ -23296,6 +23298,7 @@ }, { "body": { + "codegenName": "indices", "kind": "value", "value": { "key": { @@ -23430,6 +23433,7 @@ }, { "body": { + "codegenName": "aliases", "kind": "value", "value": { "key": { @@ -23959,6 +23963,7 @@ }, { "body": { + "codegenName": "mappings", "kind": "value", "value": { "key": { @@ -24128,6 +24133,7 @@ }, { "body": { + "codegenName": "settings", "kind": "value", "value": { "key": { @@ -28112,6 +28118,7 @@ }, { "body": { + "codegenName": "pipelines", "kind": "value", "value": { "key": { @@ -28675,6 +28682,7 @@ }, { "body": { + "codegenName": "pipelines", "kind": "value", "value": { "key": { @@ -30057,7 +30065,7 @@ "MlEvaluateDataFrameRequestExample4": { "description": "Run `POST _ml/data_frame/_evaluate` to evaluate the testing error of a regression job for an annotated index. The term query in the body limits evaluation to be performed on the test split only. The `actual_field` contains the ground truth for house prices. The `predicted_field` contains the house price calculated by the regression analysis.\n", "summary": "Regression example 1", - "value": "{\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n }\n}" + "value": "{\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n }\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n}" }, "MlEvaluateDataFrameRequestExample5": { "description": "Run `POST _ml/data_frame/_evaluate` to evaluate the training error of a regression job for an annotated index. The term query in the body limits evaluation to be performed on the training split only. The `actual_field` contains the ground truth for house prices. The `predicted_field` contains the house price calculated by the regression analysis.\n", @@ -32400,6 +32408,7 @@ }, { "body": { + "codegenName": "documents", "kind": "value", "value": { "kind": "array_of", @@ -37390,7 +37399,7 @@ "MultiTermVectorsRequestExample2": { "description": "Run `POST /my-index-000001/_mtermvectors`. If all requested documents are in same index and the parameters are the same, you can use a simplified syntax.\n", "summary": "Simplified syntax", - "value": "{\n \"ids\": [ \"1\", \"2\" ],\n \"parameters\": {\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n }\n}" + "value": "{\n \"ids\": [ \"1\", \"2\" ],\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n}" }, "MultiTermVectorsRequestExample3": { "description": "Run `POST /_mtermvectors` to generate term vectors for artificial documents provided in the body of the request. The mapping used is determined by the specified `_index`.\n", @@ -41138,6 +41147,7 @@ }, { "body": { + "codegenName": "analytics", "kind": "value", "value": { "key": { @@ -41904,6 +41914,7 @@ }, { "body": { + "codegenName": "vector_tiles", "kind": "value", "value": { "kind": "instance_of", diff --git a/output/schema/schema.json b/output/schema/schema.json index e83d339b7c..92ed582749 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -27770,6 +27770,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "source", "value": { "kind": "instance_of", "type": { @@ -31865,7 +31866,7 @@ "MultiTermVectorsRequestExample2": { "description": "Run `POST /my-index-000001/_mtermvectors`. If all requested documents are in same index and the parameters are the same, you can use a simplified syntax.\n", "summary": "Simplified syntax", - "value": "{\n \"ids\": [ \"1\", \"2\" ],\n \"parameters\": {\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n }\n}" + "value": "{\n \"ids\": [ \"1\", \"2\" ],\n \"fields\": [\n \"message\"\n ],\n \"term_statistics\": true\n}" }, "MultiTermVectorsRequestExample3": { "description": "Run `POST /_mtermvectors` to generate term vectors for artificial documents provided in the body of the request. The mapping used is determined by the specified `_index`.\n", @@ -42479,6 +42480,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "vector_tiles", "value": { "kind": "instance_of", "type": { @@ -113659,6 +113661,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "infos", "value": { "kind": "dictionary_of", "key": { @@ -124768,6 +124771,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "data", "value": { "kind": "instance_of", "type": { @@ -128715,6 +128719,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "lifecycles", "value": { "kind": "dictionary_of", "key": { @@ -136879,6 +136884,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "disk_usage", "value": { "kind": "user_defined_value" } @@ -136954,6 +136960,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "result", "value": { "kind": "user_defined_value" } @@ -138566,6 +138573,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "indices", "value": { "kind": "dictionary_of", "key": { @@ -138732,6 +138740,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "aliases", "value": { "kind": "dictionary_of", "key": { @@ -139333,6 +139342,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "field_mappings", "value": { "kind": "dictionary_of", "key": { @@ -139706,6 +139716,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "mappings", "value": { "kind": "dictionary_of", "key": { @@ -140124,6 +140135,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "settings", "value": { "kind": "dictionary_of", "key": { @@ -140229,6 +140241,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "templates", "value": { "kind": "dictionary_of", "key": { @@ -140793,6 +140806,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "result", "value": { "kind": "user_defined_value" } @@ -142775,6 +142789,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "statuses", "value": { "kind": "dictionary_of", "key": { @@ -143636,6 +143651,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "infos", "value": { "kind": "dictionary_of", "key": { @@ -156968,6 +156984,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "pipelines", "value": { "kind": "dictionary_of", "key": { @@ -158997,6 +159014,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "pipelines", "value": { "kind": "dictionary_of", "key": { @@ -174234,7 +174252,7 @@ "MlEvaluateDataFrameRequestExample4": { "description": "Run `POST _ml/data_frame/_evaluate` to evaluate the testing error of a regression job for an annotated index. The term query in the body limits evaluation to be performed on the test split only. The `actual_field` contains the ground truth for house prices. The `predicted_field` contains the house price calculated by the regression analysis.\n", "summary": "Regression example 1", - "value": "{\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n }\n}" + "value": "{\n \"index\": \"house_price_predictions\",\n \"query\": {\n \"bool\": {\n \"filter\": [\n {\n \"term\": {\n \"ml.is_training\": false\n }\n }\n ]\n }\n },\n \"evaluation\": {\n \"regression\": {\n \"actual_field\": \"price\",\n \"predicted_field\": \"ml.price_prediction\",\n \"metrics\": {\n \"r_squared\": {},\n \"mse\": {},\n \"msle\": {\n \"offset\": 10\n },\n \"huber\": {\n \"delta\": 1.5\n }\n }\n }\n }\n}" }, "MlEvaluateDataFrameRequestExample5": { "description": "Run `POST _ml/data_frame/_evaluate` to evaluate the training error of a regression job for an annotated index. The term query in the body limits evaluation to be performed on the training split only. The `actual_field` contains the ground truth for house prices. The `predicted_field` contains the house price calculated by the regression analysis.\n", @@ -179420,6 +179438,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "documents", "value": { "kind": "array_of", "value": { @@ -196059,6 +196078,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "capabilities", "value": { "kind": "dictionary_of", "key": { @@ -196294,6 +196314,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "capabilities", "value": { "kind": "dictionary_of", "key": { @@ -197401,6 +197422,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "analytics", "value": { "kind": "dictionary_of", "key": { @@ -198338,6 +198360,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "result", "value": { "kind": "user_defined_value" } @@ -203864,6 +203887,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "result", "value": { "kind": "dictionary_of", "key": { @@ -205049,6 +205073,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "privileges", "value": { "kind": "dictionary_of", "key": { @@ -205131,6 +205156,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "roles", "value": { "kind": "dictionary_of", "key": { @@ -205413,6 +205439,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "role_mappings", "value": { "kind": "dictionary_of", "key": { @@ -205496,6 +205523,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "service_accoutns", "value": { "kind": "dictionary_of", "key": { @@ -206261,6 +206289,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "users", "value": { "kind": "dictionary_of", "key": { @@ -208431,6 +208460,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "result", "value": { "kind": "dictionary_of", "key": { @@ -214136,6 +214166,7 @@ "kind": "response", "body": { "kind": "value", + "codegenName": "lifecycles", "value": { "kind": "dictionary_of", "key": {