Skip to content

Commit 7077ff6

Browse files
committed
Rebase to add CLI support, add new make target
1 parent 40fb988 commit 7077ff6

File tree

5 files changed

+25966
-11377
lines changed

5 files changed

+25966
-11377
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ transform-expand-generics: ## Create a new schema with all generics expanded
5252
@npm run transform-expand-generics --prefix compiler
5353

5454
transform-to-openapi: ## Generate the OpenAPI definition from the compiled schema
55-
@npm run transform-to-openapi -- --schema output/schema/schema.json --flavor stack --output output/openapi/elasticsearch-openapi.json
56-
@npm run transform-to-openapi -- --schema output/schema/schema.json --flavor serverless --output output/openapi/elasticsearch-serverless-openapi.json
55+
@npm run transform-to-openapi -- --schema output/schema/schema.json --flavor stack --lift-enum-descriptions --output output/openapi/elasticsearch-openapi.json
56+
@npm run transform-to-openapi -- --schema output/schema/schema.json --flavor serverless --lift-enum-descriptions --output output/openapi/elasticsearch-serverless-openapi.json
57+
58+
transform-to-openapi-for-docs: ## Generate the OpenAPI definition tailored for API docs generation
59+
@npm run transform-to-openapi -- --schema output/schema/schema.json --flavor stack --lift-enum-descriptions --merge-multipath-endpoints --output output/openapi/elasticsearch-openapi-docs.json
5760

5861
filter-for-serverless: ## Generate the serverless version from the compiled schema
5962
@npm run --prefix compiler filter-by-availability -- --serverless --visibility=public --input ../output/schema/schema.json --output ../output/output/openapi/elasticsearch-serverless-openapi.json

compiler-rs/clients_schema_to_openapi/src/cli.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ pub struct Cli {
2020
#[argh(option, default = "SchemaFlavor::All")]
2121
pub flavor: SchemaFlavor,
2222

23-
/// add enum descriptions to property descriptions [default = true]
24-
#[argh(option, default = "true")]
25-
pub lift_enum_descriptions: bool,
26-
2723
/// generate only this namespace (can be repeated)
2824
#[argh(option)]
2925
pub namespace: Vec<String>,
26+
27+
/// add enum descriptions to property descriptions [default = true]
28+
#[argh(switch)]
29+
pub lift_enum_descriptions: bool,
30+
31+
/// merge endpoints with multiple paths into a single OpenAPI operation [default = false]
32+
#[argh(switch)]
33+
pub merge_multipath_endpoints: bool,
3034
}
3135

3236
use derive_more::FromStr;
@@ -42,20 +46,21 @@ pub enum SchemaFlavor {
4246
}
4347

4448
impl From<Cli> for Configuration {
45-
fn from(val: Cli) -> Configuration {
46-
let flavor = match val.flavor {
49+
fn from(cli: Cli) -> Configuration {
50+
let flavor = match cli.flavor {
4751
SchemaFlavor::All => None,
4852
SchemaFlavor::Serverless => Some(Flavor::Serverless),
4953
SchemaFlavor::Stack => Some(Flavor::Stack),
5054
};
5155

5256
Configuration {
5357
flavor,
54-
lift_enum_descriptions: val.lift_enum_descriptions,
55-
namespaces: if val.namespace.is_empty() {
58+
lift_enum_descriptions: cli.lift_enum_descriptions,
59+
merge_multipath_endpoints: cli.merge_multipath_endpoints,
60+
namespaces: if cli.namespace.is_empty() {
5661
None
5762
} else {
58-
Some(val.namespace)
63+
Some(cli.namespace)
5964
},
6065
}
6166
}
Binary file not shown.

0 commit comments

Comments
 (0)