Rewrite to a API trait.

This commit is contained in:
2026-01-11 14:12:54 +01:00
parent ea9f05b048
commit 88f8cf76ef
45 changed files with 1384 additions and 1030 deletions

View File

@@ -17,6 +17,7 @@ docs/Location.md
docs/LocationId.md
docs/Login.md
docs/OwnGameRequestBody.md
docs/OwnedGame.md
docs/Participants.md
docs/Registration.md
docs/RenameGameRequestBody.md
@@ -43,6 +44,7 @@ src/models/location_id.rs
src/models/login.rs
src/models/mod.rs
src/models/own_game_request_body.rs
src/models/owned_game.rs
src/models/participants.rs
src/models/registration.rs
src/models/rename_game_request_body.rs

View File

@@ -11,8 +11,8 @@ serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart"] }
async-trait = "^0.1"
reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart", "stream"] }
[features]
default = ["native-tls"]
native-tls = ["reqwest/native-tls"]

View File

@@ -69,6 +69,7 @@ Class | Method | HTTP request | Description
- [LocationId](docs/LocationId.md)
- [Login](docs/Login.md)
- [OwnGameRequestBody](docs/OwnGameRequestBody.md)
- [OwnedGame](docs/OwnedGame.md)
- [Participants](docs/Participants.md)
- [Registration](docs/Registration.md)
- [RenameGameRequestBody](docs/RenameGameRequestBody.md)

View File

@@ -4,7 +4,20 @@ fn main() {
println!("cargo::rerun-if-changed=../backend-actix/gamenight-api.yaml");
let _ =
Command::new("openapi-generator")
.args(["generate", "-i", "../backend-actix/gamenight-api.yaml", "-g", "rust", "--additional-properties=withSeparateModelsAndApi=true,modelPackage=gamenight_model,apiPackage=gamenight_api,packageName=gamenight-api-client-rs,packageVersion=0.1.0"])
.args([
"generate",
"-i",
"../backend-actix/gamenight-api.yaml",
"-g",
"rust",
"--additional-properties=\
withSeparateModelsAndApi=true,\
library=reqwest-trait,\
modelPackage=gamenight_model,\
apiPackage=gamenight_api,\
packageName=gamenight-api-client-rs,\
packageVersion=0.1.0"
])
.output()
.expect("Failed to generate models sources for the gamenight API");
}

View File

@@ -476,7 +476,7 @@ Name | Type | Description | Required | Notes
## owned_games_get
> Vec<String> owned_games_get(user_id)
> Vec<models::OwnedGame> owned_games_get(user_id)
### Parameters
@@ -488,7 +488,7 @@ Name | Type | Description | Required | Notes
### Return type
**Vec<String>**
[**Vec<models::OwnedGame>**](OwnedGame.md)
### Authorization

View File

@@ -6,6 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **String** | |
**name** | **String** | |
**location_id** | Option<**String**> | | [optional]
**datetime** | **String** | |
**owner_id** | **String** | |

View File

@@ -0,0 +1,12 @@
# OwnedGame
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**game_id** | **String** | |
**location_id** | Option<**String**> | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

File diff suppressed because it is too large Load Diff

View File

@@ -114,3 +114,4 @@ impl From<&str> for ContentType {
pub mod default_api;
pub mod configuration;

View File

@@ -5,7 +5,6 @@ extern crate serde_repr;
extern crate serde;
extern crate serde_json;
extern crate url;
extern crate reqwest;
pub mod apis;
pub mod models;

View File

@@ -17,6 +17,8 @@ pub struct Gamenight {
pub id: String,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "location_id", skip_serializing_if = "Option::is_none")]
pub location_id: Option<String>,
#[serde(rename = "datetime")]
pub datetime: String,
#[serde(rename = "owner_id")]
@@ -28,6 +30,7 @@ impl Gamenight {
Gamenight {
id,
name,
location_id: None,
datetime,
owner_id,
}

View File

@@ -26,6 +26,8 @@ pub mod login;
pub use self::login::Login;
pub mod own_game_request_body;
pub use self::own_game_request_body::OwnGameRequestBody;
pub mod owned_game;
pub use self::owned_game::OwnedGame;
pub mod participants;
pub use self::participants::Participants;
pub mod registration;

View File

@@ -0,0 +1,30 @@
/*
* Gamenight
*
* Api specification for a Gamenight server
*
* The version of the OpenAPI document: 1.0
* Contact: dennis@brentj.es
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct OwnedGame {
#[serde(rename = "game_id")]
pub game_id: String,
#[serde(rename = "location_id", skip_serializing_if = "Option::is_none")]
pub location_id: Option<String>,
}
impl OwnedGame {
pub fn new(game_id: String) -> OwnedGame {
OwnedGame {
game_id,
location_id: None,
}
}
}