Skip to content

Commit 9b09bb4

Browse files
committed
Add README, commit generated OpenAPI schema
1 parent 22c046e commit 9b09bb4

File tree

5 files changed

+91356
-3
lines changed

5 files changed

+91356
-3
lines changed

openapi-converter/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
Workspace members:
44

55
* [`clients_schema`](./clients_schema/): a Rust implementation of the [Elasticsearch specification schema](https://github.com/elastic/elasticsearch-specification/blob/main/compiler/src/model/metamodel.ts) metamodel.
6-
* [`openapi_to_clients_schema`](./openapi_to_clients_schema): translate an OpenAPI specification to an Elasticsearch
6+
* [`clients_schema_to_openapi`](./clients_schema_to_openapi): conversion of the `schema.json` format to OpenAPI. Supersedes [elasticsearch-openapi](https://github.com/elastic/elasticsearch-openapi).
7+
* [`openapi_to_clients_schema`](./openapi_to_clients_schema): experimental, translate an OpenAPI specification to an Elasticsearch
78
schema that can be used as input for code generation.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Schema.json to OpenAPI converter
2+
3+
This project provides a utility to convert the [schema.json](../../output/schema) file representing the Elasticsearch API specification to OpenAPI version 3.0.3.
4+
5+
The conversion pipeline is the following:
6+
7+
```mermaid
8+
flowchart LR
9+
ts[TypeScript API]
10+
schema[schema.json]
11+
openapi[OpenAPI]
12+
13+
ts --> schema
14+
schema --> openapi
15+
```
16+
17+
This is still a work in progress. The OpenAPI specification generated from the current `schema.json` can be found in the [output/openapi](../../output/openapi) directory.

openapi-converter/clients_schema_to_openapi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn convert_schema_file(path: impl AsRef<Path>, endpoint_filter: fn(e: &Endpo
3030
}
3131

3232
let openapi = convert_schema(&model, endpoint_filter)?;
33-
//serde_json::to_writer_pretty(BufWriter::new(out), &openapi)?;
33+
serde_json::to_writer_pretty(BufWriter::new(out), &openapi)?;
3434
Ok(())
3535
}
3636

openapi-converter/clients_schema_to_openapi/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ fn main() -> anyhow::Result<()> {
2222
"../output/schema/schema-no-generics.json",
2323
|e| true,
2424
//|e| e.name == "search",
25-
std::io::stdout()
25+
std::fs::File::create("../output/openapi/elasticsearch-openapi.json")?
26+
//std::io::stdout()
2627
)?;
2728

2829
Ok(())

0 commit comments

Comments
 (0)