From 96f57d753a8a1b40dd66e7cd2c7c7fe9962eb85a Mon Sep 17 00:00:00 2001 From: pyrite Date: Wed, 10 Sep 2025 15:25:01 +0200 Subject: [PATCH 1/2] fix(codegen): fix raw repr enums when there is no description --- torn-api-codegen/Cargo.toml | 2 +- torn-api-codegen/src/model/enum.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/torn-api-codegen/Cargo.toml b/torn-api-codegen/Cargo.toml index d700456..038e453 100644 --- a/torn-api-codegen/Cargo.toml +++ b/torn-api-codegen/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "torn-api-codegen" authors = ["Pyrit [2111649]"] -version = "0.7.3" +version = "0.7.4" edition = "2021" description = "Contains the v2 torn API model descriptions and codegen for the bindings" license = { workspace = true } diff --git a/torn-api-codegen/src/model/enum.rs b/torn-api-codegen/src/model/enum.rs index 8a2d556..fbc54a9 100644 --- a/torn-api-codegen/src/model/enum.rs +++ b/torn-api-codegen/src/model/enum.rs @@ -444,7 +444,7 @@ impl Enum { if shared.len() >= 2 { for (idx, variant) in shared.into_iter().enumerate() { let label = idx + 1; - variant.name = format!("Variant{}", label); + variant.name = format!("Variant{label}"); if let EnumVariantValue::Tuple(values) = &mut variant.value { if let [EnumVariantTupleValue::Enum { name, inner, .. }] = values.as_mut_slice() { @@ -475,7 +475,6 @@ impl Enum { let name = format_ident!("{}", self.name); let desc = self.description.as_ref().map(|d| { quote! { - #repr #[doc = #d] } }); @@ -540,6 +539,7 @@ impl Enum { #[derive(Debug, Clone, PartialEq, #(#derives),*)] #[cfg_attr(feature = "strum", derive(strum::EnumIs, strum::EnumTryAs))] #serde_attr + #repr pub enum #name { #(#variants),* } From df31458f3aaa753d10f699e7b2b4bf4358285e9c Mon Sep 17 00:00:00 2001 From: pyrite Date: Wed, 10 Sep 2025 15:25:38 +0200 Subject: [PATCH 2/2] chore(api): update schema --- Cargo.lock | 4 +-- torn-api/openapi.json | 59 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1014be3..1944953 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2294,7 +2294,7 @@ dependencies = [ [[package]] name = "torn-api" -version = "1.7.4" +version = "1.7.5" dependencies = [ "bon", "bytes", @@ -2316,7 +2316,7 @@ dependencies = [ [[package]] name = "torn-api-codegen" -version = "0.7.3" +version = "0.7.4" dependencies = [ "heck", "indexmap", diff --git a/torn-api/openapi.json b/torn-api/openapi.json index c3f6ccf..cf5fd8b 100644 --- a/torn-api/openapi.json +++ b/torn-api/openapi.json @@ -3,7 +3,7 @@ "info": { "title": "Torn API", "description": "\n * The development of Torn's API v2 is still ongoing.\n * If selections remain unaltered, they will default to the API v1 version.\n * Unlike API v1, API v2 accepts both selections and IDs as path and query parameters.\n * If any discrepancies or errors are found, please submit a [bug report](https://www.torn.com/forums.php#/p=forums&f=19&b=0&a=0) on the Torn Forums.\n * In case you're using bots to check for changes on openapi.json file, make sure to specificy a custom user-agent header - CloudFlare sometimes prevents requests from default user-agents.", - "version": "3.0.12" + "version": "3.0.18" }, "servers": [ { @@ -8473,6 +8473,13 @@ "E" ] }, + "UserDonatorStatusEnum": { + "type": "string", + "enum": [ + "Donator", + "Subscriber" + ] + }, "JobTypeEnum": { "type": "string", "enum": [ @@ -8556,7 +8563,9 @@ "Tourist", "Nudist", "Sage", - "Coward" + "Coward", + "Newcomer", + "Deserter" ] }, "UserRankEnum": { @@ -15194,6 +15203,7 @@ "id", "type_id", "name", + "rating", "position", "days_in_company" ], @@ -15213,6 +15223,10 @@ "name": { "type": "string" }, + "rating": { + "type": "integer", + "format": "int32" + }, "position": { "type": "string" }, @@ -15297,7 +15311,8 @@ "forum_posts", "karma", "last_action", - "life" + "life", + "donator_status" ], "properties": { "id": { @@ -15316,6 +15331,16 @@ "title": { "$ref": "#/components/schemas/UserTitleEnum" }, + "donator_status": { + "oneOf": [ + { + "$ref": "#/components/schemas/UserDonatorStatusEnum" + }, + { + "type": "null" + } + ] + }, "age": { "description": "Age in days.", "type": "integer", @@ -17561,6 +17586,25 @@ }, "type": "object" }, + "UserOrganizedCrimeError": { + "required": [ + "code", + "error" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32", + "enum": [ + 27 + ] + }, + "error": { + "type": "string" + } + }, + "type": "object" + }, "UserOrganizedCrimeResponse": { "required": [ "organizedCrime" @@ -17571,6 +17615,9 @@ { "$ref": "#/components/schemas/FactionCrime" }, + { + "$ref": "#/components/schemas/UserOrganizedCrimeError" + }, { "type": "null" } @@ -22169,7 +22216,8 @@ "description", "details", "state", - "until" + "until", + "color" ], "properties": { "description": { @@ -22188,6 +22236,9 @@ "state": { "type": "string" }, + "color": { + "type": "string" + }, "until": { "oneOf": [ {