two small BTreeMap
-related changes
import `BTreeMap` instead of qualified path use `BTreeMap` instead of `serde_json::Map`
This commit is contained in:
parent
cad6890128
commit
9e3279e7ed
5 changed files with 17 additions and 13 deletions
|
@ -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 {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue