summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
Diffstat (limited to 'generator')
-rw-r--r--generator/src/main.rs4
-rw-r--r--generator/src/methods.rs1
-rw-r--r--generator/src/structs.rs3
3 files changed, 5 insertions, 3 deletions
diff --git a/generator/src/main.rs b/generator/src/main.rs
index 9a5abee..64173bf 100644
--- a/generator/src/main.rs
+++ b/generator/src/main.rs
@@ -105,7 +105,7 @@ fn schema_type_name(
// Checking for a space filters that out
(Some(title), _) if !title.contains(' ') => title.to_string(),
(_, Some(definition_name)) => definition_name.to_string(),
- (_, None) => "serde_json::Map<String, serde_json::Value>".to_string(),
+ (_, None) => "BTreeMap<String, serde_json::Value>".to_string(),
}
}
};
@@ -223,7 +223,7 @@ fn schema_subtype_name(
let additional = additional.deref(spec)?;
let mut additional_ty = crate::schema_type_name(spec, None, additional)?;
schema_subtype_name(spec, parent_name, name, additional, &mut additional_ty)?;
- *ty = format!("std::collections::BTreeMap<String, {additional_ty}>");
+ *ty = format!("BTreeMap<String, {additional_ty}>");
true
}
Schema {
diff --git a/generator/src/methods.rs b/generator/src/methods.rs
index c0f614c..6877437 100644
--- a/generator/src/methods.rs
+++ b/generator/src/methods.rs
@@ -6,6 +6,7 @@ use std::fmt::Write;
pub fn create_methods(spec: &OpenApiV2) -> eyre::Result<String> {
let mut s = String::new();
s.push_str("use crate::ForgejoError;\n");
+ s.push_str("use std::collections::BTreeMap;");
s.push_str("use super::structs::*;\n");
s.push_str("\n");
s.push_str("impl crate::Forgejo {\n");
diff --git a/generator/src/structs.rs b/generator/src/structs.rs
index 6f2e917..0b4de08 100644
--- a/generator/src/structs.rs
+++ b/generator/src/structs.rs
@@ -6,6 +6,7 @@ use std::fmt::Write;
pub fn create_structs(spec: &OpenApiV2) -> eyre::Result<String> {
let mut s = String::new();
s.push_str("use crate::StructureError;");
+ s.push_str("use std::collections::BTreeMap;");
if let Some(definitions) = &spec.definitions {
for (name, schema) in definitions {
let strukt = create_struct_for_definition(&spec, name, schema)?;
@@ -108,7 +109,7 @@ pub fn create_struct_for_definition(
if let Some(additonal_schema) = &schema.additional_properties {
let prop_ty = crate::schema_ref_type_name(spec, additonal_schema)?;
fields.push_str("#[serde(flatten)]\n");
- fields.push_str("pub additional: std::collections::BTreeMap<String, ");
+ fields.push_str("pub additional: BTreeMap<String, ");
fields.push_str(&prop_ty);
fields.push_str(">,\n");
}