Skip to content

Commit d7d268e

Browse files
authored
Add rest-api-spec converter (#5295) (#6102)
* Add initial rest-api-spec converter * Wrap JSON data with endpoint name * Add headers * Extract visibility * Add debug logging for types * Improve type handling * Extract builting mappings * Skip empty headers * Add more mappings * Add required field to bodies * Support CommonCatQueryParameters * Fix availability/stability * Improve urls generation * Serialize description only if required? * Support more complex types * Add spec and docs for new logs streams endpoints (#5258) * Add spec and docs for new logs streams endpoints * Add @codegen name to Acked responses * Linting fix * Update specification/streams/status/examples/200_response/GetStreamsStatusResponseExample1.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Correct feature flag * Add doc-ids * Fix doc-ids * Update specification/_doc_ids/table.csv Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co> * Update specification/_doc_ids/table.csv Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co> * Add default timeouts --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co> * Update specification output * Add common cat API parameters for unit rendering (#5298) Describes the `?bytes=` and `?time=` parameters which are accepted by all the `GET _cat/...` APIs. * Edit the log streams endpoint docs (#5305) * Add speficaiton for a new rescore type (#5308) Based on PR elastic/elasticsearch#74274 * Update specification output * Update rest-api-spec (#5294) Co-authored-by: pquentin <42327+pquentin@users.noreply.github.com> * Update rest-api-spec (#5311) Co-authored-by: pquentin <42327+pquentin@users.noreply.github.com> * Commit Cargo.lock changes * Show unexpected union * Remove '| string' in query parameters * Always specify body.required * Fix type for uint * Return string for string | string[] * Skip empty descriptions * Remove redundant code comments * Specify default_value for expand_wildcards * Stop hardcoding expand_wildcards * Improve union handling * Hardcode "serialize": "bulk" endpoints * Handle deprecated URLs parts * Improve diff script * Tweak converter * Handle parameter visibility * Handle required parameters * Fix required parameters * Fix experimental indices sample APIs * Allow string[] for routing parameters * Fix type of if_version in ingest.put_pipeline * Fix type of search_type in rank_eval * Fix type of CategoryId * Mark find_structure column_names as string | string[] * Allow empty URLs * Handle number|string special cases * Handle Fleet IndexName | IndexCase case * Fail on unknown cases * Improve diff * Remvope file committed by mistake * Add optional body to three ML APIs * Fix ccs_minimize_roundtrips default value * Fix description for parameter that does not accept comma-separated values * Stop trying to document private API * Remove parameter in find_structure API * Fix find_stucture format enum * Remove cruft * Remove more cruft * Update Rust edition to 2024 and refactor conditional statements * Clarify main.rs Print at the correct place and use crate prefixes * Remove diplay() call * Add TODOs * Remove wrong doc_id from knn_search * Add body to project.tags * Run make spec-format-fix * wip * Switch to HttpMethod enum * Use http::Method and implement TryFrom * Use enums for stability and visibility * Switch parameter types to enum * Simplify BUILTING_MAPPINGS code * Add top-level Cargo.lock change * Add WASM integration for rest-api-spec generation * Fix leftovers from previous commit * Restrict WASM tracing to INFO * Add _common.json generation * Rename is_literal to get_literal * Fix indices.get_settings expand_wildcards default --------- Co-authored-by: Luke Whiting <luke.whiting@elastic.co> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: David Turner <david.turner@elastic.co> Co-authored-by: Lisa Cawley <lcawley@elastic.co> Co-authored-by: Mayya Sharipova <mayya.sharipova@elastic.co> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: pquentin <42327+pquentin@users.noreply.github.com> Co-authored-by: Laurent Saint-Félix <laurent.saintfelix@elastic.co> (cherry picked from commit 7b7e18a) # Conflicts: # compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm # specification/inference/put_groq/PutGroqRequest.ts # specification/inference/put_nvidia/PutNvidiaRequest.ts # specification/streams/logs_disable/StreamsLogsDisableRequest.ts # specification/streams/logs_enable/StreamsLogsEnableRequest.ts
1 parent 6b307c1 commit d7d268e

File tree

25 files changed

+1255
-18
lines changed

25 files changed

+1255
-18
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ clean-dep: ## Clean npm dependencies
5151
transform-expand-generics: ## Create a new schema with all generics expanded
5252
@npm run transform-expand-generics --prefix compiler
5353

54+
transform-to-rest-api-spec: ## Generate the REST API spec from the compiled schema
55+
@rm -rf specification/_json_spec/*.json
56+
@npm run transform-to-rest-api-spec --prefix compiler -- --schema output/schema/schema.json --output specification/_json_spec
57+
5458
transform-to-openapi: ## Generate the OpenAPI definition from the compiled schema
5559
@npm run transform-to-openapi -- --schema output/schema/schema.json --flavor stack --output output/openapi/elasticsearch-openapi.json
5660
@npm run transform-to-openapi -- --schema output/schema/schema.json --flavor serverless --output output/openapi/elasticsearch-serverless-openapi.json

compiler-rs/Cargo.lock

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler-rs/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"clients_schema",
55
"openapi_to_clients_schema",
66
"clients_schema_to_openapi",
7+
"clients_schema_to_rest_api_spec",
78
"compiler-wasm-lib",
89
]
910

@@ -16,6 +17,7 @@ console_error_panic_hook = "0.1"
1617
convert_case = "0.6"
1718
derive_more = "1.0.0-beta.6"
1819
either_n = "0.2"
20+
http = "1"
1921
icu_segmenter = "1"
2022
indexmap = "2"
2123
itertools = "0.14"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rest-api-output
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "clients_schema_to_rest_api_spec"
3+
version = "0.1.0"
4+
edition = "2024"
5+
publish = false
6+
7+
[dependencies]
8+
clients_schema = { path = "../clients_schema" }
9+
10+
argh = { workspace = true }
11+
serde = { workspace = true, features = ["derive"] }
12+
serde_json = { workspace = true }
13+
anyhow = { workspace = true }
14+
indexmap = { workspace = true }
15+
16+
tracing = { workspace = true }
17+
tracing-subscriber = { workspace = true }
18+
http = { workspace = true }

0 commit comments

Comments
 (0)