summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2024-03-15 23:13:24 +0100
committerCyborus <cyborus@cyborus.xyz>2024-03-15 23:13:24 +0100
commitcad68901287659878419a50568496ed3b201097a (patch)
treeb77d041c1cd44097b3bff36123b84820e57ed0a5
parentadjust created user's email in test (diff)
downloadforgejo-api-cad68901287659878419a50568496ed3b201097a.tar.xz
forgejo-api-cad68901287659878419a50568496ed3b201097a.zip
remove structs that only exist for their `additional` field
-rw-r--r--generator/src/main.rs17
-rw-r--r--src/generated/methods.rs2
-rw-r--r--src/generated/structs.rs71
3 files changed, 23 insertions, 67 deletions
diff --git a/generator/src/main.rs b/generator/src/main.rs
index 8b6272e..9a5abee 100644
--- a/generator/src/main.rs
+++ b/generator/src/main.rs
@@ -203,17 +203,27 @@ fn schema_subtype_name(
let b = match schema {
Schema {
_type: Some(SchemaType::One(Primitive::Object)),
+ properties: Some(_),
+ ..
+ }
+ | Schema {
+ _type: Some(SchemaType::One(Primitive::String)),
+ _enum: Some(_),
..
} => {
*ty = format!("{parent_name}{}", name.to_pascal_case());
true
}
Schema {
- _type: Some(SchemaType::One(Primitive::String)),
- _enum: Some(_enum),
+ _type: Some(SchemaType::One(Primitive::Object)),
+ properties: None,
+ additional_properties: Some(additional),
..
} => {
- *ty = format!("{parent_name}{}", name.to_pascal_case());
+ 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}>");
true
}
Schema {
@@ -246,6 +256,7 @@ fn schema_subtypes(
match schema {
Schema {
_type: Some(SchemaType::One(Primitive::Object)),
+ properties: Some(_),
..
} => {
let name = format!("{parent_name}{}", name.to_pascal_case());
diff --git a/src/generated/methods.rs b/src/generated/methods.rs
index 45a1a2c..9afc13e 100644
--- a/src/generated/methods.rs
+++ b/src/generated/methods.rs
@@ -4119,7 +4119,7 @@ impl crate::Forgejo {
&self,
owner: &str,
repo: &str,
- ) -> Result<RepoGetLanguagesResponse, ForgejoError> {
+ ) -> Result<std::collections::BTreeMap<String, u64>, ForgejoError> {
let request = self
.get(&format!("repos/{owner}/{repo}/languages"))
.build()?;
diff --git a/src/generated/structs.rs b/src/generated/structs.rs
index 101a420..34764b6 100644
--- a/src/generated/structs.rs
+++ b/src/generated/structs.rs
@@ -727,7 +727,7 @@ pub struct CreateTeamOption {
pub name: String,
pub permission: Option<CreateTeamOptionPermission>,
pub units: Option<Vec<String>>,
- pub units_map: Option<CreateTeamOptionUnitsMap>,
+ pub units_map: Option<std::collections::BTreeMap<String, String>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
@@ -739,12 +739,6 @@ pub enum CreateTeamOptionPermission {
#[serde(rename = "admin")]
Admin,
}
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct CreateTeamOptionUnitsMap {
- #[serde(flatten)]
- pub additional: std::collections::BTreeMap<String, String>,
-}
-
/// CreateUserOption create user options
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct CreateUserOption {
@@ -898,16 +892,10 @@ pub struct EditHookOption {
pub active: Option<bool>,
pub authorization_header: Option<String>,
pub branch_filter: Option<String>,
- pub config: Option<EditHookOptionConfig>,
+ pub config: Option<std::collections::BTreeMap<String, String>>,
pub events: Option<Vec<String>>,
}
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct EditHookOptionConfig {
- #[serde(flatten)]
- pub additional: std::collections::BTreeMap<String, String>,
-}
-
/// EditIssueCommentOption options for editing a comment
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct EditIssueCommentOption {
@@ -1088,7 +1076,7 @@ pub struct EditTeamOption {
pub name: String,
pub permission: Option<EditTeamOptionPermission>,
pub units: Option<Vec<String>>,
- pub units_map: Option<EditTeamOptionUnitsMap>,
+ pub units_map: Option<std::collections::BTreeMap<String, String>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
@@ -1100,12 +1088,6 @@ pub enum EditTeamOptionPermission {
#[serde(rename = "admin")]
Admin,
}
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct EditTeamOptionUnitsMap {
- #[serde(flatten)]
- pub additional: std::collections::BTreeMap<String, String>,
-}
-
/// EditUserOption edit user options
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct EditUserOption {
@@ -1369,7 +1351,7 @@ pub struct Hook {
pub active: Option<bool>,
pub authorization_header: Option<String>,
pub branch_filter: Option<String>,
- pub config: Option<HookConfig>,
+ pub config: Option<std::collections::BTreeMap<String, String>>,
#[serde(with = "time::serde::rfc3339::option")]
pub created_at: Option<time::OffsetDateTime>,
pub events: Option<Vec<String>>,
@@ -1380,12 +1362,6 @@ pub struct Hook {
pub updated_at: Option<time::OffsetDateTime>,
}
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct HookConfig {
- #[serde(flatten)]
- pub additional: std::collections::BTreeMap<String, String>,
-}
-
/// Identity for a person's identity like an author or committer
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Identity {
@@ -1471,23 +1447,11 @@ pub struct IssueDeadline {
/// IssueFormField represents a form field
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct IssueFormField {
- pub attributes: Option<IssueFormFieldAttributes>,
+ pub attributes: Option<std::collections::BTreeMap<String, serde_json::Value>>,
pub id: Option<String>,
#[serde(rename = "type")]
pub r#type: Option<String>,
- pub validations: Option<IssueFormFieldValidations>,
-}
-
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct IssueFormFieldAttributes {
- #[serde(flatten)]
- pub additional: std::collections::BTreeMap<String, serde_json::Value>,
-}
-
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct IssueFormFieldValidations {
- #[serde(flatten)]
- pub additional: std::collections::BTreeMap<String, serde_json::Value>,
+ pub validations: Option<std::collections::BTreeMap<String, serde_json::Value>>,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
@@ -1746,7 +1710,7 @@ pub struct NewIssuePinsAllowed {
/// 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)]
pub struct NodeInfo {
- pub metadata: Option<NodeInfoMetadata>,
+ pub metadata: Option<serde_json::Map<String, serde_json::Value>>,
#[serde(rename = "openRegistrations")]
pub open_registrations: Option<bool>,
pub protocols: Option<Vec<String>>,
@@ -1756,9 +1720,6 @@ pub struct NodeInfo {
pub version: Option<String>,
}
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct NodeInfoMetadata {}
-
/// NodeInfoServices contains the third party sites this server can connect to via their application API
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct NodeInfoServices {
@@ -2347,7 +2308,7 @@ pub struct Team {
pub organization: Option<Organization>,
pub permission: Option<TeamPermission>,
pub units: Option<Vec<String>>,
- pub units_map: Option<TeamUnitsMap>,
+ pub units_map: Option<std::collections::BTreeMap<String, String>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
@@ -2363,12 +2324,6 @@ pub enum TeamPermission {
#[serde(rename = "owner")]
Owner,
}
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct TeamUnitsMap {
- #[serde(flatten)]
- pub additional: std::collections::BTreeMap<String, String>,
-}
-
/// TimeStamp defines a timestamp
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct TimeStamp {}
@@ -2755,11 +2710,6 @@ impl TryFrom<&reqwest::header::HeaderMap> for CommitListHeaders {
})
}
}
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct LanguageStatisticsResponse {
- #[serde(flatten)]
- pub additional: std::collections::BTreeMap<String, u64>,
-}
pub struct ErrorHeaders {
pub message: Option<String>,
@@ -4600,11 +4550,6 @@ impl std::fmt::Display for IssueListLabelsQuery {
Ok(())
}
}
-#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
-pub struct RepoGetLanguagesResponse {
- #[serde(flatten)]
- pub additional: std::collections::BTreeMap<String, u64>,
-}
pub struct RepoGetRawFileOrLfsQuery {
/// The name of the commit/branch/tag. Default the repository’s default branch (usually master)