diff --git a/Cargo.lock b/Cargo.lock
index aa29b2e..65a0c28 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -227,7 +227,6 @@ dependencies = [
"iana-time-zone",
"js-sys",
"num-traits",
- "serde",
"wasm-bindgen",
"windows-link",
]
@@ -2272,11 +2271,10 @@ dependencies = [
[[package]]
name = "torn-api"
-version = "1.3.0"
+version = "1.2.0"
dependencies = [
"bon",
"bytes",
- "chrono",
"futures",
"http",
"prettyplease",
@@ -2293,7 +2291,7 @@ dependencies = [
[[package]]
name = "torn-api-codegen"
-version = "0.3.0"
+version = "0.2.4"
dependencies = [
"heck",
"indexmap",
diff --git a/torn-api-codegen/Cargo.toml b/torn-api-codegen/Cargo.toml
index a2ad99d..cec8fba 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.3.0"
+version = "0.2.4"
edition = "2021"
description = "Contains the v2 torn API model descriptions and codegen for the bindings"
license-file = { workspace = true }
diff --git a/torn-api-codegen/openapi.json b/torn-api-codegen/openapi.json
index e70979a..c5ddb7a 100644
--- a/torn-api-codegen/openapi.json
+++ b/torn-api-codegen/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": "1.7.0"
+ "version": "1.6.1"
},
"servers": [
{
@@ -1226,69 +1226,6 @@
"x-stability": "Stable"
}
},
- "/user/reports": {
- "get": {
- "tags": [
- "User"
- ],
- "summary": "Get your reports",
- "description": "Requires limited access key.
\n * The default limit is set to 25. However, the limit can be set to 100 for the 'stats' category.",
- "operationId": "6ba15a813fe1cc014564e9dba892e022",
- "parameters": [
- {
- "name": "cat",
- "in": "query",
- "description": "Used to filter reports with a specific type.",
- "required": false,
- "schema": {
- "$ref": "#/components/schemas/ReportTypeEnum"
- }
- },
- {
- "name": "target",
- "in": "query",
- "description": "Get reports for a specific player by passing their player ID.",
- "required": false,
- "schema": {
- "$ref": "#/components/schemas/UserId"
- }
- },
- {
- "$ref": "#/components/parameters/ApiLimit100Default20"
- },
- {
- "$ref": "#/components/parameters/ApiOffset"
- },
- {
- "$ref": "#/components/parameters/ApiTimestamp"
- },
- {
- "$ref": "#/components/parameters/ApiComment"
- },
- {
- "$ref": "#/components/parameters/ApiKeyLimited"
- }
- ],
- "responses": {
- "200": {
- "description": "Successful operation",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ReportsResponse"
- }
- }
- }
- }
- },
- "security": [
- {
- "api_key": []
- }
- ],
- "x-stability": "Unstable"
- }
- },
"/user/revives": {
"get": {
"tags": [
@@ -2850,69 +2787,6 @@
"x-stability": "Stable"
}
},
- "/faction/reports": {
- "get": {
- "tags": [
- "Faction"
- ],
- "summary": "Get faction reports",
- "description": "Requires limited access key.
\n * The default limit is set to 25. However, the limit can be set to 100 for the 'stats' category.",
- "operationId": "e8bd37f10cc5e0e8d6694bb306f3a1e4",
- "parameters": [
- {
- "name": "cat",
- "in": "query",
- "description": "Used to filter reports with a specific type.",
- "required": false,
- "schema": {
- "$ref": "#/components/schemas/ReportTypeEnum"
- }
- },
- {
- "name": "target",
- "in": "query",
- "description": "Get reports for a specific player by passing their player ID.",
- "required": false,
- "schema": {
- "$ref": "#/components/schemas/UserId"
- }
- },
- {
- "$ref": "#/components/parameters/ApiLimit100Default20"
- },
- {
- "$ref": "#/components/parameters/ApiOffset"
- },
- {
- "$ref": "#/components/parameters/ApiTimestamp"
- },
- {
- "$ref": "#/components/parameters/ApiComment"
- },
- {
- "$ref": "#/components/parameters/ApiKeyLimited"
- }
- ],
- "responses": {
- "200": {
- "description": "Successful operation",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ReportsResponse"
- }
- }
- }
- }
- },
- "security": [
- {
- "api_key": []
- }
- ],
- "x-stability": "Unstable"
- }
- },
"/faction/revives": {
"get": {
"tags": [
@@ -4124,6 +3998,15 @@
{
"$ref": "#/components/parameters/ApiOffsetNoDefault"
},
+ {
+ "name": "cat",
+ "in": "query",
+ "description": "Selection category",
+ "required": false,
+ "schema": {
+ "type": "string"
+ }
+ },
{
"$ref": "#/components/parameters/ApiTimestamp"
},
@@ -6100,37 +5983,6 @@
"E"
]
},
- "CountryEnum": {
- "type": "string",
- "enum": [
- "Mexico",
- "Hawaii",
- "South Africa",
- "Japan",
- "China",
- "Argentina",
- "Switzerland",
- "Canada",
- "United Kingdom",
- "UAE",
- "Cayman Islands"
- ]
- },
- "ReportTypeEnum": {
- "type": "string",
- "enum": [
- "mostwanted",
- "money",
- "stats",
- "references",
- "friendorfoe",
- "companyfinancials",
- "truelevel",
- "stockanalysis",
- "anonymousbounties",
- "investment"
- ]
- },
"ApiKeyAccessTypeEnum": {
"type": "string",
"enum": [
@@ -11598,551 +11450,6 @@
},
"type": "object"
},
- "ReportBase": {
- "required": [
- "type",
- "target_id",
- "reporter_id",
- "faction_id",
- "timestamp"
- ],
- "properties": {
- "type": {
- "$ref": "#/components/schemas/ReportTypeEnum"
- },
- "target_id": {
- "description": "The target ID if applicable.",
- "oneOf": [
- {
- "$ref": "#/components/schemas/UserId"
- },
- {
- "type": "null"
- }
- ]
- },
- "reporter_id": {
- "$ref": "#/components/schemas/UserId"
- },
- "faction_id": {
- "description": "Reporter's faction ID if applicable.",
- "oneOf": [
- {
- "$ref": "#/components/schemas/FactionId"
- },
- {
- "type": "null"
- }
- ]
- },
- "timestamp": {
- "type": "integer",
- "format": "int32"
- }
- },
- "type": "object"
- },
- "ReportWarrantDetails": {
- "required": [
- "id",
- "name",
- "warrant"
- ],
- "properties": {
- "id": {
- "$ref": "#/components/schemas/UserId"
- },
- "name": {
- "type": "string"
- },
- "warrant": {
- "type": "integer",
- "format": "int32"
- }
- },
- "type": "object"
- },
- "ReportMostWanted": {
- "required": [
- "top",
- "notable"
- ],
- "properties": {
- "top": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ReportWarrantDetails"
- }
- },
- "notable": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ReportWarrantDetails"
- }
- }
- },
- "type": "object"
- },
- "ReportMoney": {
- "required": [
- "money"
- ],
- "properties": {
- "money": {
- "type": "integer",
- "format": "int32"
- }
- },
- "type": "object"
- },
- "ReportInvestment": {
- "required": [
- "amount",
- "until"
- ],
- "properties": {
- "amount": {
- "type": "integer",
- "format": "int64"
- },
- "until": {
- "type": "integer",
- "format": "int32"
- }
- },
- "type": "object"
- },
- "ReportTrueLevel": {
- "required": [
- "level"
- ],
- "properties": {
- "level": {
- "type": "integer",
- "format": "int32"
- }
- },
- "type": "object"
- },
- "ReportStats": {
- "required": [
- "strength",
- "speed",
- "dexterity",
- "defense",
- "total"
- ],
- "properties": {
- "strength": {
- "oneOf": [
- {
- "type": "integer",
- "format": "int64"
- },
- {
- "type": "null"
- }
- ]
- },
- "speed": {
- "oneOf": [
- {
- "type": "integer",
- "format": "int64"
- },
- {
- "type": "null"
- }
- ]
- },
- "dexterity": {
- "oneOf": [
- {
- "type": "integer",
- "format": "int64"
- },
- {
- "type": "null"
- }
- ]
- },
- "defense": {
- "oneOf": [
- {
- "type": "integer",
- "format": "int64"
- },
- {
- "type": "null"
- }
- ]
- },
- "total": {
- "oneOf": [
- {
- "type": "integer",
- "format": "int64"
- },
- {
- "type": "null"
- }
- ]
- }
- },
- "type": "object"
- },
- "ReportHistoryFaction": {
- "required": [
- "id",
- "name",
- "joined",
- "left"
- ],
- "properties": {
- "id": {
- "$ref": "#/components/schemas/FactionId"
- },
- "name": {
- "type": "string"
- },
- "joined": {
- "type": "string",
- "format": "date"
- },
- "left": {
- "oneOf": [
- {
- "type": "string",
- "format": "date"
- },
- {
- "type": "null"
- }
- ]
- }
- },
- "type": "object"
- },
- "ReportHistoryCompany": {
- "required": [
- "id",
- "name",
- "joined",
- "left"
- ],
- "properties": {
- "id": {
- "$ref": "#/components/schemas/CompanyId"
- },
- "name": {
- "type": "string"
- },
- "joined": {
- "type": "string",
- "format": "date"
- },
- "left": {
- "oneOf": [
- {
- "type": "string",
- "format": "date"
- },
- {
- "type": "null"
- }
- ]
- }
- },
- "type": "object"
- },
- "ReportHistory": {
- "required": [
- "factions",
- "companies"
- ],
- "properties": {
- "factions": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ReportHistoryFaction"
- }
- },
- "companies": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ReportHistoryCompany"
- }
- }
- },
- "type": "object"
- },
- "ReportFriendOrFoeUser": {
- "required": [
- "id",
- "name"
- ],
- "properties": {
- "id": {
- "$ref": "#/components/schemas/UserId"
- },
- "name": {
- "type": "string"
- }
- },
- "type": "object"
- },
- "ReportFriendOrFoe": {
- "required": [
- "friends",
- "enemies"
- ],
- "properties": {
- "friends": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ReportFriendOrFoeUser"
- }
- },
- "enemies": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ReportFriendOrFoeUser"
- }
- }
- },
- "type": "object"
- },
- "ReportCompanyFinancials": {
- "required": [
- "balance",
- "employees",
- "wages"
- ],
- "properties": {
- "balance": {
- "type": "integer",
- "format": "int64"
- },
- "employees": {
- "type": "integer",
- "format": "int32"
- },
- "wages": {
- "required": [
- "highest",
- "lowest",
- "average"
- ],
- "properties": {
- "highest": {
- "type": "integer",
- "format": "int32"
- },
- "lowest": {
- "type": "integer",
- "format": "int32"
- },
- "average": {
- "type": "integer",
- "format": "int32"
- }
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "ReportStockAnalysis": {
- "required": [
- "items"
- ],
- "properties": {
- "items": {
- "type": "array",
- "items": {
- "required": [
- "country",
- "item",
- "trip_duration",
- "hourly_profit"
- ],
- "properties": {
- "country": {
- "$ref": "#/components/schemas/CountryEnum"
- },
- "item": {
- "required": [
- "id",
- "name",
- "stock",
- "price",
- "value",
- "due"
- ],
- "properties": {
- "id": {
- "$ref": "#/components/schemas/ItemId"
- },
- "name": {
- "type": "string"
- },
- "price": {
- "type": "integer",
- "format": "int32"
- },
- "value": {
- "type": "integer",
- "format": "int32"
- },
- "due": {
- "oneOf": [
- {
- "type": "integer",
- "format": "int32"
- },
- {
- "type": "null"
- }
- ]
- }
- },
- "type": "object"
- },
- "trip_duration": {
- "type": "integer",
- "format": "int32"
- },
- "hourly_profit": {
- "type": "integer",
- "format": "int32"
- }
- },
- "type": "object"
- }
- }
- },
- "type": "object"
- },
- "ReportAnonymousBounties": {
- "required": [
- "bounties"
- ],
- "properties": {
- "bounties": {
- "type": "array",
- "items": {
- "required": [
- "bounty",
- "user",
- "text"
- ],
- "properties": {
- "text": {
- "type": "string"
- },
- "bounty": {
- "type": "integer",
- "format": "int64"
- },
- "user": {
- "oneOf": [
- {
- "required": [
- "id",
- "name"
- ],
- "properties": {
- "id": {
- "$ref": "#/components/schemas/UserId"
- },
- "name": {
- "type": "string"
- }
- },
- "type": "object"
- },
- {
- "type": "null"
- }
- ]
- }
- },
- "type": "object"
- }
- }
- },
- "type": "object"
- },
- "ReportReport": {
- "required": [
- "report"
- ],
- "properties": {
- "report": {
- "oneOf": [
- {
- "$ref": "#/components/schemas/ReportMoney"
- },
- {
- "$ref": "#/components/schemas/ReportStats"
- },
- {
- "$ref": "#/components/schemas/ReportMostWanted"
- },
- {
- "$ref": "#/components/schemas/ReportHistory"
- },
- {
- "$ref": "#/components/schemas/ReportFriendOrFoe"
- },
- {
- "$ref": "#/components/schemas/ReportCompanyFinancials"
- },
- {
- "$ref": "#/components/schemas/ReportTrueLevel"
- },
- {
- "$ref": "#/components/schemas/ReportStockAnalysis"
- },
- {
- "$ref": "#/components/schemas/ReportAnonymousBounties"
- },
- {
- "$ref": "#/components/schemas/ReportInvestment"
- }
- ]
- }
- },
- "type": "object"
- },
- "Report": {
- "allOf": [
- {
- "$ref": "#/components/schemas/ReportBase"
- },
- {
- "$ref": "#/components/schemas/ReportReport"
- }
- ]
- },
- "ReportsResponse": {
- "required": [
- "reports",
- "_metadata"
- ],
- "properties": {
- "reports": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Report"
- }
- },
- "_metadata": {
- "$ref": "#/components/schemas/RequestMetadataWithLinks"
- }
- },
- "type": "object"
- },
"UserCurrentEducation": {
"required": [
"id",
@@ -13105,7 +12412,7 @@
],
"properties": {
"value": {
- "type": "number",
+ "type": "integer",
"format": "float"
},
"rank": {
@@ -13127,7 +12434,7 @@
"rank": {
"oneOf": [
{
- "type": "integer",
+ "type": "number",
"format": "int32"
},
{
@@ -22296,16 +21603,6 @@
"minimum": 1
}
},
- "ApiTarget": {
- "name": "target",
- "in": "query",
- "required": false,
- "schema": {
- "type": "integer",
- "format": "int32",
- "minimum": 1
- }
- },
"ApiSort": {
"name": "sort",
"in": "query",
diff --git a/torn-api-codegen/src/model/mod.rs b/torn-api-codegen/src/model/mod.rs
index 6b9c313..e230952 100644
--- a/torn-api-codegen/src/model/mod.rs
+++ b/torn-api-codegen/src/model/mod.rs
@@ -61,7 +61,10 @@ impl Model {
#[cfg(test)]
mod test {
use super::*;
- use crate::openapi::schema::OpenApiSchema;
+ use crate::{
+ model::r#enum::{EnumRepr, EnumVariant},
+ openapi::schema::OpenApiSchema,
+ };
#[test]
fn resolve_newtypes() {
diff --git a/torn-api-codegen/src/model/object.rs b/torn-api-codegen/src/model/object.rs
index 8b96376..c29dcbe 100644
--- a/torn-api-codegen/src/model/object.rs
+++ b/torn-api-codegen/src/model/object.rs
@@ -15,7 +15,6 @@ pub enum PrimitiveType {
I64,
String,
Float,
- DateTime,
}
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -36,9 +35,6 @@ impl PropertyType {
Self::Primitive(PrimitiveType::String) => {
Some(format_ident!("String").into_token_stream())
}
- Self::Primitive(PrimitiveType::DateTime) => {
- Some(quote! { chrono::DateTime })
- }
Self::Primitive(PrimitiveType::Float) => Some(format_ident!("f64").into_token_stream()),
Self::Ref(path) => {
let name = path.strip_prefix("#/components/schemas/")?;
@@ -215,7 +211,6 @@ impl Property {
PrimitiveType::Float
}
(Some("string"), None) => PrimitiveType::String,
- (Some("string"), Some("date")) => PrimitiveType::DateTime,
(Some("boolean"), None) => PrimitiveType::Bool,
_ => return None,
};
diff --git a/torn-api-codegen/src/model/parameter.rs b/torn-api-codegen/src/model/parameter.rs
index 613b8a9..23daff1 100644
--- a/torn-api-codegen/src/model/parameter.rs
+++ b/torn-api-codegen/src/model/parameter.rs
@@ -303,7 +303,12 @@ The default value [Self::{}](self::{}#variant.{})"#,
let mut code = inner.codegen().unwrap_or_default();
let name = format_ident!("{}", outer_name);
- let inner_ty = items.codegen_type_name(&inner_name);
+ let inner_ty = if matches!(items.as_ref(), ParameterType::Schema { type_name: _ }) {
+ let inner_name = format_ident!("{}", inner_name);
+ quote! { crate::models::#inner_name }
+ } else {
+ items.codegen_type_name(&inner_name).to_token_stream()
+ };
code.extend(quote! {
#[derive(Debug, Clone)]
diff --git a/torn-api/Cargo.toml b/torn-api/Cargo.toml
index 71fdb08..b9c49dc 100644
--- a/torn-api/Cargo.toml
+++ b/torn-api/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "torn-api"
-version = "1.3.0"
+version = "1.2.0"
edition = "2021"
description = "Auto-generated bindings for the v2 torn api"
license-file = { workspace = true }
@@ -31,13 +31,12 @@ futures = { version = "0.3", default-features = false, features = [
"std",
"async-await",
] }
-chrono = { version = "0.4.41", features = ["serde"] }
[dev-dependencies]
tokio = { version = "1", features = ["full"] }
[build-dependencies]
-torn-api-codegen = { path = "../torn-api-codegen", version = "0.3.0" }
+torn-api-codegen = { path = "../torn-api-codegen", version = "0.2.3" }
syn = { workspace = true, features = ["parsing"] }
proc-macro2 = { workspace = true }
prettyplease = "0.2"
diff --git a/torn-api/src/scopes.rs b/torn-api/src/scopes.rs
index ea548f0..9910897 100644
--- a/torn-api/src/scopes.rs
+++ b/torn-api/src/scopes.rs
@@ -366,15 +366,6 @@ pub(super) mod test {
faction_scope.lookup(|b| b).await.unwrap();
}
- #[tokio::test]
- async fn faction_reports() {
- let client = test_client().await;
-
- let faction_scope = FactionScope(&client);
-
- faction_scope.reports(|b| b).await.unwrap();
- }
-
#[tokio::test]
async fn forum_categories() {
let client = test_client().await;
@@ -963,11 +954,4 @@ pub(super) mod test {
client.user().attacks(|b| b).await.unwrap();
}
-
- #[tokio::test]
- async fn user_reports() {
- let client = test_client().await;
-
- client.user().reports(|b| b).await.unwrap();
- }
}