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
|
@ -105,7 +105,7 @@ fn schema_type_name(
|
||||||
// Checking for a space filters that out
|
// Checking for a space filters that out
|
||||||
(Some(title), _) if !title.contains(' ') => title.to_string(),
|
(Some(title), _) if !title.contains(' ') => title.to_string(),
|
||||||
(_, Some(definition_name)) => definition_name.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 additional = additional.deref(spec)?;
|
||||||
let mut additional_ty = crate::schema_type_name(spec, None, additional)?;
|
let mut additional_ty = crate::schema_type_name(spec, None, additional)?;
|
||||||
schema_subtype_name(spec, parent_name, name, additional, &mut additional_ty)?;
|
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
|
true
|
||||||
}
|
}
|
||||||
Schema {
|
Schema {
|
||||||
|
|
|
@ -6,6 +6,7 @@ use std::fmt::Write;
|
||||||
pub fn create_methods(spec: &OpenApiV2) -> eyre::Result<String> {
|
pub fn create_methods(spec: &OpenApiV2) -> eyre::Result<String> {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
s.push_str("use crate::ForgejoError;\n");
|
s.push_str("use crate::ForgejoError;\n");
|
||||||
|
s.push_str("use std::collections::BTreeMap;");
|
||||||
s.push_str("use super::structs::*;\n");
|
s.push_str("use super::structs::*;\n");
|
||||||
s.push_str("\n");
|
s.push_str("\n");
|
||||||
s.push_str("impl crate::Forgejo {\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> {
|
pub fn create_structs(spec: &OpenApiV2) -> eyre::Result<String> {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
s.push_str("use crate::StructureError;");
|
s.push_str("use crate::StructureError;");
|
||||||
|
s.push_str("use std::collections::BTreeMap;");
|
||||||
if let Some(definitions) = &spec.definitions {
|
if let Some(definitions) = &spec.definitions {
|
||||||
for (name, schema) in definitions {
|
for (name, schema) in definitions {
|
||||||
let strukt = create_struct_for_definition(&spec, name, schema)?;
|
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 {
|
if let Some(additonal_schema) = &schema.additional_properties {
|
||||||
let prop_ty = crate::schema_ref_type_name(spec, additonal_schema)?;
|
let prop_ty = crate::schema_ref_type_name(spec, additonal_schema)?;
|
||||||
fields.push_str("#[serde(flatten)]\n");
|
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(&prop_ty);
|
||||||
fields.push_str(">,\n");
|
fields.push_str(">,\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::structs::*;
|
use super::structs::*;
|
||||||
use crate::ForgejoError;
|
use crate::ForgejoError;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
impl crate::Forgejo {
|
impl crate::Forgejo {
|
||||||
/// Returns the Person actor for a user
|
/// Returns the Person actor for a user
|
||||||
|
@ -4119,7 +4120,7 @@ impl crate::Forgejo {
|
||||||
&self,
|
&self,
|
||||||
owner: &str,
|
owner: &str,
|
||||||
repo: &str,
|
repo: &str,
|
||||||
) -> Result<std::collections::BTreeMap<String, u64>, ForgejoError> {
|
) -> Result<BTreeMap<String, u64>, ForgejoError> {
|
||||||
let request = self
|
let request = self
|
||||||
.get(&format!("repos/{owner}/{repo}/languages"))
|
.get(&format!("repos/{owner}/{repo}/languages"))
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::StructureError;
|
use crate::StructureError;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
/// APIError is an api error with a message
|
/// APIError is an api error with a message
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct APIError {
|
pub struct APIError {
|
||||||
|
@ -496,7 +497,7 @@ pub enum CreateHookOptionType {
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct CreateHookOptionConfig {
|
pub struct CreateHookOptionConfig {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub additional: std::collections::BTreeMap<String, String>,
|
pub additional: BTreeMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CreateIssueCommentOption options for creating a comment on an issue
|
/// CreateIssueCommentOption options for creating a comment on an issue
|
||||||
|
@ -727,7 +728,7 @@ pub struct CreateTeamOption {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub permission: Option<CreateTeamOptionPermission>,
|
pub permission: Option<CreateTeamOptionPermission>,
|
||||||
pub units: Option<Vec<String>>,
|
pub units: Option<Vec<String>>,
|
||||||
pub units_map: Option<std::collections::BTreeMap<String, String>>,
|
pub units_map: Option<BTreeMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
@ -892,7 +893,7 @@ pub struct EditHookOption {
|
||||||
pub active: Option<bool>,
|
pub active: Option<bool>,
|
||||||
pub authorization_header: Option<String>,
|
pub authorization_header: Option<String>,
|
||||||
pub branch_filter: Option<String>,
|
pub branch_filter: Option<String>,
|
||||||
pub config: Option<std::collections::BTreeMap<String, String>>,
|
pub config: Option<BTreeMap<String, String>>,
|
||||||
pub events: Option<Vec<String>>,
|
pub events: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1076,7 +1077,7 @@ pub struct EditTeamOption {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub permission: Option<EditTeamOptionPermission>,
|
pub permission: Option<EditTeamOptionPermission>,
|
||||||
pub units: Option<Vec<String>>,
|
pub units: Option<Vec<String>>,
|
||||||
pub units_map: Option<std::collections::BTreeMap<String, String>>,
|
pub units_map: Option<BTreeMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
@ -1351,7 +1352,7 @@ pub struct Hook {
|
||||||
pub active: Option<bool>,
|
pub active: Option<bool>,
|
||||||
pub authorization_header: Option<String>,
|
pub authorization_header: Option<String>,
|
||||||
pub branch_filter: Option<String>,
|
pub branch_filter: Option<String>,
|
||||||
pub config: Option<std::collections::BTreeMap<String, String>>,
|
pub config: Option<BTreeMap<String, String>>,
|
||||||
#[serde(with = "time::serde::rfc3339::option")]
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
pub created_at: Option<time::OffsetDateTime>,
|
pub created_at: Option<time::OffsetDateTime>,
|
||||||
pub events: Option<Vec<String>>,
|
pub events: Option<Vec<String>>,
|
||||||
|
@ -1447,11 +1448,11 @@ pub struct IssueDeadline {
|
||||||
/// IssueFormField represents a form field
|
/// IssueFormField represents a form field
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct IssueFormField {
|
pub struct IssueFormField {
|
||||||
pub attributes: Option<std::collections::BTreeMap<String, serde_json::Value>>,
|
pub attributes: Option<BTreeMap<String, serde_json::Value>>,
|
||||||
pub id: Option<String>,
|
pub id: Option<String>,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub r#type: Option<String>,
|
pub r#type: Option<String>,
|
||||||
pub validations: Option<std::collections::BTreeMap<String, serde_json::Value>>,
|
pub validations: Option<BTreeMap<String, serde_json::Value>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
|
@ -1710,7 +1711,7 @@ pub struct NewIssuePinsAllowed {
|
||||||
/// NodeInfo contains standardized way of exposing metadata about a server running one of the distributed social networks
|
/// NodeInfo contains standardized way of exposing metadata about a server running one of the distributed social networks
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct NodeInfo {
|
pub struct NodeInfo {
|
||||||
pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
|
pub metadata: Option<BTreeMap<String, serde_json::Value>>,
|
||||||
#[serde(rename = "openRegistrations")]
|
#[serde(rename = "openRegistrations")]
|
||||||
pub open_registrations: Option<bool>,
|
pub open_registrations: Option<bool>,
|
||||||
pub protocols: Option<Vec<String>>,
|
pub protocols: Option<Vec<String>>,
|
||||||
|
@ -2308,7 +2309,7 @@ pub struct Team {
|
||||||
pub organization: Option<Organization>,
|
pub organization: Option<Organization>,
|
||||||
pub permission: Option<TeamPermission>,
|
pub permission: Option<TeamPermission>,
|
||||||
pub units: Option<Vec<String>>,
|
pub units: Option<Vec<String>>,
|
||||||
pub units_map: Option<std::collections::BTreeMap<String, String>>,
|
pub units_map: Option<BTreeMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
|
Loading…
Reference in a new issue