Skip to content

Commit 390fa6e

Browse files
committed
0.0.10
1 parent d75e415 commit 390fa6e

9 files changed

Lines changed: 354 additions & 4 deletions

File tree

cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# SOFTWARE.
2222
[package]
2323
name = "fakehub"
24-
version = "0.0.0"
24+
version = "0.0.10"
2525
edition = "2021"
2626
license = "MIT"
2727
description = """
@@ -39,7 +39,7 @@ workspace = true
3939
assert_cmd = "2.0.14"
4040

4141
[dependencies]
42-
fakehub-server = { path = "../server", version = "0.0.0" }
42+
fakehub-server = { path = "../server", version = "0.0.10", features = ["mirror_release"] }
4343
anyhow = "1.0.86"
4444
clap = { version = "4.5.7", optional = true, features = ["derive", "string"] }
4545
clap_complete = { version = "4.5.1", optional = true }

github-mirror/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "github-mirror"
3+
version = "0.0.10"
4+
authors = ["OpenAPI Generator team and contributors"]
5+
description = "GitHub's v3 REST API."
6+
license = "MIT"
7+
edition = "2021"
8+
9+
[dependencies]
10+
serde = { version = "^1.0", features = ["derive"] }
11+
serde_json = "^1.0"
12+
serde_repr = "^0.1"
13+
url = "^2.5"
14+
uuid = { version = "^1.8", features = ["serde", "v4"] }
15+
reqwest = { version = "^0.12", features = ["json", "multipart"] }
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* GitHub v3 REST API
3+
*
4+
* GitHub's v3 REST API.
5+
*
6+
* The version of the OpenAPI document: 1.1.4
7+
*
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
12+
13+
#[derive(Debug, Clone)]
14+
pub struct Configuration {
15+
pub base_path: String,
16+
pub user_agent: Option<String>,
17+
pub client: reqwest::Client,
18+
pub basic_auth: Option<BasicAuth>,
19+
pub oauth_access_token: Option<String>,
20+
pub bearer_access_token: Option<String>,
21+
pub api_key: Option<ApiKey>,
22+
}
23+
24+
pub type BasicAuth = (String, Option<String>);
25+
26+
#[derive(Debug, Clone)]
27+
pub struct ApiKey {
28+
pub prefix: Option<String>,
29+
pub key: String,
30+
}
31+
32+
33+
impl Configuration {
34+
pub fn new() -> Configuration {
35+
Configuration::default()
36+
}
37+
}
38+
39+
impl Default for Configuration {
40+
fn default() -> Self {
41+
Configuration {
42+
base_path: "https://api.github.com".to_owned(),
43+
user_agent: Some("OpenAPI-Generator/1.1.4/rust".to_owned()),
44+
client: reqwest::Client::new(),
45+
basic_auth: None,
46+
oauth_access_token: None,
47+
bearer_access_token: None,
48+
api_key: None,
49+
}
50+
}
51+
}

github-mirror/src/apis/meta_api.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* GitHub v3 REST API
3+
*
4+
* GitHub's v3 REST API.
5+
*
6+
* The version of the OpenAPI document: 1.1.4
7+
*
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
12+
use reqwest;
13+
use serde::{Deserialize, Serialize};
14+
use crate::{apis::ResponseContent, models};
15+
use super::{Error, configuration};
16+
17+
18+
/// struct for typed errors of method [`meta_slash_root`]
19+
#[derive(Debug, Clone, Serialize, Deserialize)]
20+
#[serde(untagged)]
21+
pub enum MetaSlashRootError {
22+
UnknownValue(serde_json::Value),
23+
}
24+
25+
26+
/// Get Hypermedia links to resources accessible in GitHub's REST API
27+
pub async fn meta_slash_root(configuration: &configuration::Configuration, ) -> Result<models::MetaRoot200Response, Error<MetaSlashRootError>> {
28+
let local_var_configuration = configuration;
29+
30+
let local_var_client = &local_var_configuration.client;
31+
32+
let local_var_uri_str = format!("{}/", local_var_configuration.base_path);
33+
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
34+
35+
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
36+
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
37+
}
38+
39+
let local_var_req = local_var_req_builder.build()?;
40+
let local_var_resp = local_var_client.execute(local_var_req).await?;
41+
42+
let local_var_status = local_var_resp.status();
43+
let local_var_content = local_var_resp.text().await?;
44+
45+
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
46+
serde_json::from_str(&local_var_content).map_err(Error::from)
47+
} else {
48+
let local_var_entity: Option<MetaSlashRootError> = serde_json::from_str(&local_var_content).ok();
49+
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
50+
Err(Error::ResponseError(local_var_error))
51+
}
52+
}
53+

github-mirror/src/apis/mod.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
use std::error;
2+
use std::fmt;
3+
4+
#[derive(Debug, Clone)]
5+
pub struct ResponseContent<T> {
6+
pub status: reqwest::StatusCode,
7+
pub content: String,
8+
pub entity: Option<T>,
9+
}
10+
11+
#[derive(Debug)]
12+
pub enum Error<T> {
13+
Reqwest(reqwest::Error),
14+
Serde(serde_json::Error),
15+
Io(std::io::Error),
16+
ResponseError(ResponseContent<T>),
17+
}
18+
19+
impl <T> fmt::Display for Error<T> {
20+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21+
let (module, e) = match self {
22+
Error::Reqwest(e) => ("reqwest", e.to_string()),
23+
Error::Serde(e) => ("serde", e.to_string()),
24+
Error::Io(e) => ("IO", e.to_string()),
25+
Error::ResponseError(e) => ("response", format!("status code {}", e.status)),
26+
};
27+
write!(f, "error in {}: {}", module, e)
28+
}
29+
}
30+
31+
impl <T: fmt::Debug> error::Error for Error<T> {
32+
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
33+
Some(match self {
34+
Error::Reqwest(e) => e,
35+
Error::Serde(e) => e,
36+
Error::Io(e) => e,
37+
Error::ResponseError(_) => return None,
38+
})
39+
}
40+
}
41+
42+
impl <T> From<reqwest::Error> for Error<T> {
43+
fn from(e: reqwest::Error) -> Self {
44+
Error::Reqwest(e)
45+
}
46+
}
47+
48+
impl <T> From<serde_json::Error> for Error<T> {
49+
fn from(e: serde_json::Error) -> Self {
50+
Error::Serde(e)
51+
}
52+
}
53+
54+
impl <T> From<std::io::Error> for Error<T> {
55+
fn from(e: std::io::Error) -> Self {
56+
Error::Io(e)
57+
}
58+
}
59+
60+
pub fn urlencode<T: AsRef<str>>(s: T) -> String {
61+
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
62+
}
63+
64+
pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
65+
if let serde_json::Value::Object(object) = value {
66+
let mut params = vec![];
67+
68+
for (key, value) in object {
69+
match value {
70+
serde_json::Value::Object(_) => params.append(&mut parse_deep_object(
71+
&format!("{}[{}]", prefix, key),
72+
value,
73+
)),
74+
serde_json::Value::Array(array) => {
75+
for (i, value) in array.iter().enumerate() {
76+
params.append(&mut parse_deep_object(
77+
&format!("{}[{}][{}]", prefix, key, i),
78+
value,
79+
));
80+
}
81+
},
82+
serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())),
83+
_ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
84+
}
85+
}
86+
87+
return params;
88+
}
89+
90+
unimplemented!("Only objects are supported with style=deepObject")
91+
}
92+
93+
pub mod meta_api;
94+
95+
pub mod configuration;

github-mirror/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![allow(unused_imports)]
2+
#![allow(clippy::too_many_arguments)]
3+
4+
extern crate serde_repr;
5+
extern crate serde;
6+
extern crate serde_json;
7+
extern crate url;
8+
extern crate reqwest;
9+
10+
pub mod apis;
11+
pub mod models;
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* GitHub v3 REST API
3+
*
4+
* GitHub's v3 REST API.
5+
*
6+
* The version of the OpenAPI document: 1.1.4
7+
*
8+
* Generated by: https://openapi-generator.tech
9+
*/
10+
11+
use crate::models;
12+
use serde::{Deserialize, Serialize};
13+
14+
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15+
pub struct MetaRoot200Response {
16+
#[serde(rename = "current_user_url")]
17+
pub current_user_url: String,
18+
#[serde(rename = "current_user_authorizations_html_url")]
19+
pub current_user_authorizations_html_url: String,
20+
#[serde(rename = "authorizations_url")]
21+
pub authorizations_url: String,
22+
#[serde(rename = "code_search_url")]
23+
pub code_search_url: String,
24+
#[serde(rename = "commit_search_url")]
25+
pub commit_search_url: String,
26+
#[serde(rename = "emails_url")]
27+
pub emails_url: String,
28+
#[serde(rename = "emojis_url")]
29+
pub emojis_url: String,
30+
#[serde(rename = "events_url")]
31+
pub events_url: String,
32+
#[serde(rename = "feeds_url")]
33+
pub feeds_url: String,
34+
#[serde(rename = "followers_url")]
35+
pub followers_url: String,
36+
#[serde(rename = "following_url")]
37+
pub following_url: String,
38+
#[serde(rename = "gists_url")]
39+
pub gists_url: String,
40+
#[serde(rename = "hub_url", skip_serializing_if = "Option::is_none")]
41+
pub hub_url: Option<String>,
42+
#[serde(rename = "issue_search_url")]
43+
pub issue_search_url: String,
44+
#[serde(rename = "issues_url")]
45+
pub issues_url: String,
46+
#[serde(rename = "keys_url")]
47+
pub keys_url: String,
48+
#[serde(rename = "label_search_url")]
49+
pub label_search_url: String,
50+
#[serde(rename = "notifications_url")]
51+
pub notifications_url: String,
52+
#[serde(rename = "organization_url")]
53+
pub organization_url: String,
54+
#[serde(rename = "organization_repositories_url")]
55+
pub organization_repositories_url: String,
56+
#[serde(rename = "organization_teams_url")]
57+
pub organization_teams_url: String,
58+
#[serde(rename = "public_gists_url")]
59+
pub public_gists_url: String,
60+
#[serde(rename = "rate_limit_url")]
61+
pub rate_limit_url: String,
62+
#[serde(rename = "repository_url")]
63+
pub repository_url: String,
64+
#[serde(rename = "repository_search_url")]
65+
pub repository_search_url: String,
66+
#[serde(rename = "current_user_repositories_url")]
67+
pub current_user_repositories_url: String,
68+
#[serde(rename = "starred_url")]
69+
pub starred_url: String,
70+
#[serde(rename = "starred_gists_url")]
71+
pub starred_gists_url: String,
72+
#[serde(rename = "topic_search_url", skip_serializing_if = "Option::is_none")]
73+
pub topic_search_url: Option<String>,
74+
#[serde(rename = "user_url")]
75+
pub user_url: String,
76+
#[serde(rename = "user_organizations_url")]
77+
pub user_organizations_url: String,
78+
#[serde(rename = "user_repositories_url")]
79+
pub user_repositories_url: String,
80+
#[serde(rename = "user_search_url")]
81+
pub user_search_url: String,
82+
}
83+
84+
impl MetaRoot200Response {
85+
pub fn new(current_user_url: String, current_user_authorizations_html_url: String, authorizations_url: String, code_search_url: String, commit_search_url: String, emails_url: String, emojis_url: String, events_url: String, feeds_url: String, followers_url: String, following_url: String, gists_url: String, issue_search_url: String, issues_url: String, keys_url: String, label_search_url: String, notifications_url: String, organization_url: String, organization_repositories_url: String, organization_teams_url: String, public_gists_url: String, rate_limit_url: String, repository_url: String, repository_search_url: String, current_user_repositories_url: String, starred_url: String, starred_gists_url: String, user_url: String, user_organizations_url: String, user_repositories_url: String, user_search_url: String) -> MetaRoot200Response {
86+
MetaRoot200Response {
87+
current_user_url,
88+
current_user_authorizations_html_url,
89+
authorizations_url,
90+
code_search_url,
91+
commit_search_url,
92+
emails_url,
93+
emojis_url,
94+
events_url,
95+
feeds_url,
96+
followers_url,
97+
following_url,
98+
gists_url,
99+
hub_url: None,
100+
issue_search_url,
101+
issues_url,
102+
keys_url,
103+
label_search_url,
104+
notifications_url,
105+
organization_url,
106+
organization_repositories_url,
107+
organization_teams_url,
108+
public_gists_url,
109+
rate_limit_url,
110+
repository_url,
111+
repository_search_url,
112+
current_user_repositories_url,
113+
starred_url,
114+
starred_gists_url,
115+
topic_search_url: None,
116+
user_url,
117+
user_organizations_url,
118+
user_repositories_url,
119+
user_search_url,
120+
}
121+
}
122+
}
123+

github-mirror/src/models/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod meta_root_200_response;
2+
pub use self::meta_root_200_response::MetaRoot200Response;

server/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# SOFTWARE.
2222
[package]
2323
name = "fakehub-server"
24-
version = "0.0.0"
24+
version = "0.0.10"
2525
edition = "2021"
2626
license = "MIT"
2727
description = """
@@ -38,7 +38,7 @@ path = "src/lib.rs"
3838
workspace = true
3939

4040
[dependencies]
41-
openapi = { path = "../github-mirror", version = "1.1.4" }
41+
github-mirror = { path = "../github-mirror", version = "0.0.10" }
4242
anyhow = "1.0.86"
4343
serde = { version = "1.0.203", features = ["derive"] }
4444
serde_json = "1.0.117"

0 commit comments

Comments
 (0)