Skip to content

Commit ccc2dbb

Browse files
committed
Handle Fleet IndexName | IndexCase case
1 parent dc9b048 commit ccc2dbb

File tree

1 file changed

+21
-0
lines changed
  • compiler-rs/clients_schema_to_rest_api_spec/src

1 file changed

+21
-0
lines changed

compiler-rs/clients_schema_to_rest_api_spec/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,25 @@ fn is_list_enum(union: &UnionOf) -> Option<TypeName> {
264264
return None;
265265
}
266266

267+
fn is_index_name_and_alias(union: &UnionOf) -> bool {
268+
// Fleet APIs use IndexName | IndexAlias for index in path
269+
if union.items.len() == 2 {
270+
let mut has_index_name = false;
271+
let mut has_index_alias = false;
272+
for item in &union.items {
273+
if let ValueOf::InstanceOf(instance) = item {
274+
if instance.typ == TypeName::new("_types", "IndexName") {
275+
has_index_name = true;
276+
} else if instance.typ == TypeName::new("_types", "IndexAlias") {
277+
has_index_alias = true;
278+
}
279+
}
280+
}
281+
return has_index_name && has_index_alias;
282+
}
283+
false
284+
}
285+
267286
fn is_literal(instance: &InstanceOf) -> Option<String> {
268287
let key = (instance.typ.namespace.as_str(), instance.typ.name.as_str());
269288
if let Some(&mapped_type) = BUILTIN_MAPPINGS.iter().find(|&&(k, _)| k == key).map(|(_, v)| v) {
@@ -279,6 +298,8 @@ fn get_type_name(value_of: &ValueOf, types: &IndexMap<TypeName, TypeDefinition>)
279298
ValueOf::ArrayOf(_) => "list".to_string(),
280299
ValueOf::UnionOf(union) => if let Some(_) = is_list_enum(union) {
281300
"list"
301+
} else if is_index_name_and_alias(union) {
302+
"string"
282303
} else {
283304
tracing::warn!("{:?}", union);
284305
todo!()

0 commit comments

Comments
 (0)