Skip to content

Commit 13edad5

Browse files
l-trottaflobernd
authored andcommitted
fixed openapi translation, regenerate
1 parent 93ea8c6 commit 13edad5

File tree

8 files changed

+431
-544
lines changed

8 files changed

+431
-544
lines changed

compiler-rs/clients_schema/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ pub enum ServerDefault {
380380
pub enum Variants {
381381
ExternalTag(ExternalTag),
382382
InternalTag(InternalTag),
383+
Untagged(Untagged),
383384
Container(Container),
384385
}
385386

@@ -404,6 +405,13 @@ pub struct InternalTag {
404405
pub default_tag: Option<String>,
405406
}
406407

408+
#[derive(Debug, Clone, Serialize, Deserialize)]
409+
#[serde(rename_all = "camelCase")]
410+
pub struct Untagged {
411+
#[serde(default)]
412+
pub non_exhaustive: bool,
413+
}
414+
407415
#[derive(Debug, Clone, Serialize, Deserialize)]
408416
#[serde(rename_all = "camelCase")]
409417
pub struct Container {
@@ -799,6 +807,7 @@ impl TypeAlias {
799807
pub enum TypeAliasVariants {
800808
ExternalTag(ExternalTag),
801809
InternalTag(InternalTag),
810+
Untagged(Untagged),
802811
}
803812

804813
//------------------------------------------------------------------------------------------------------------

compiler-rs/clients_schema_to_openapi/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
use std::path::{Path, PathBuf};
19+
use anyhow::bail;
1920

2021
use clap::{Parser, ValueEnum};
2122
use clients_schema::{Availabilities, Visibility};
@@ -71,7 +72,10 @@ impl Cli {
7172
std::fs::read_to_string(self.schema)?
7273
};
7374

74-
let mut model: clients_schema::IndexedModel = serde_json::from_str(&json)?;
75+
let mut model: clients_schema::IndexedModel = match serde_json::from_str(&json) {
76+
Ok(indexed_model) => indexed_model,
77+
Err(e) => bail!("cannot parse schema json: {}", e)
78+
};
7579

7680
if let Some(flavor) = self.flavor {
7781
if flavor != SchemaFlavor::All {

compiler-rs/clients_schema_to_openapi/src/schemas.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ impl<'a> TypesAndComponents<'a> {
395395
extensions: Default::default(),
396396
});
397397
}
398+
Some(TypeAliasVariants::Untagged(_tag)) => {
399+
}
398400
};
399401

400402
Ok(schema)
Binary file not shown.

compiler-rs/openapi_to_clients_schema/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn generate_schema_kind_one_of(
323323
let mut variants: Option<TypeAliasVariants> = None;
324324

325325
// TODO: do we want to allow untagged unions (those that are disambiguated by inspecting property names)?
326-
326+
327327
if let Some(discriminator) = discriminator {
328328
variants = Some(TypeAliasVariants::InternalTag(InternalTag {
329329
default_tag: None,

output/openapi/elasticsearch-serverless-openapi.json

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

0 commit comments

Comments
 (0)