tangled
alpha
login
or
join now
eldridge.cam
/
cartography
0
fork
atom
Trading card city builder game?
0
fork
atom
overview
issues
pulls
pipelines
tidying up openapi spec
eldridge.cam
1 month ago
2d2ad703
90007a14
verified
This commit was signed with the committer's
known signature
.
eldridge.cam
SSH Key Fingerprint:
SHA256:MAgO4sya2MgvdgUjSGKAO0lQ9X2HQp1Jb+x/Tpeeims=
0/0
Waiting for spindle ...
+30
-4
4 changed files
expand all
collapse all
unified
split
Cargo.lock
Cargo.toml
src
api
list_card_types.rs
main.rs
+13
Cargo.lock
···
156
156
"tokio-stream",
157
157
"tracing",
158
158
"utoipa",
159
159
+
"utoipa-scalar",
159
160
"uuid",
160
161
]
161
162
···
1920
1921
"proc-macro2",
1921
1922
"quote",
1922
1923
"syn",
1924
1924
+
]
1925
1925
+
1926
1926
+
[[package]]
1927
1927
+
name = "utoipa-scalar"
1928
1928
+
version = "0.3.0"
1929
1929
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1930
1930
+
checksum = "59559e1509172f6b26c1cdbc7247c4ddd1ac6560fe94b584f81ee489b141f719"
1931
1931
+
dependencies = [
1932
1932
+
"axum",
1933
1933
+
"serde",
1934
1934
+
"serde_json",
1935
1935
+
"utoipa",
1923
1936
]
1924
1937
1925
1938
[[package]]
+5
Cargo.toml
···
3
3
version = "0.1.0"
4
4
authors = ["Cameron Eldridge <cameldridge@gmail.com>"]
5
5
edition = "2021"
6
6
+
description = """
7
7
+
Cartography game server.
8
8
+
"""
9
9
+
license = "MIT"
6
10
7
11
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
12
···
21
25
tokio-stream = { version = "0.1.18", features = ["sync"] }
22
26
tracing = "0.1.44"
23
27
utoipa = "5.4.0"
28
28
+
utoipa-scalar = { version = "0.3.0", features = ["axum"] }
24
29
uuid = { version = "1.20.0", features = ["serde", "v7"] }
+1
src/api/list_card_types.rs
···
15
15
get,
16
16
path = "/api/v1/cardtypes",
17
17
description = "List all available card types.",
18
18
+
tag = "Global",
18
19
responses(
19
20
(status = OK, description = "Successfully listed all card types.", body = ListCardTypesResponse),
20
21
),
+11
-4
src/main.rs
···
5
5
6
6
use std::net::IpAddr;
7
7
8
8
-
use axum::{Extension, Json};
8
8
+
use axum::{Extension, Json, response::Html};
9
9
use utoipa::OpenApi;
10
10
+
use utoipa_scalar::Scalar;
10
11
11
11
-
/// Cartography API
12
12
#[derive(OpenApi)]
13
13
-
#[openapi(paths(api::list_card_types::list_card_types))]
13
13
+
#[openapi(
14
14
+
paths(api::list_card_types::list_card_types),
15
15
+
tags((name = "Global", description = "Publicly available global data about the Cartography game.")),
16
16
+
)]
14
17
struct ApiDoc;
15
18
16
19
#[tokio::main]
···
38
41
.route("/play/ws", axum::routing::any(api::ws::v1))
39
42
.route(
40
43
"/api/openapi.json",
41
41
-
axum::routing::get(|| async move { Json(ApiDoc::openapi()) }),
44
44
+
axum::routing::get(Json(ApiDoc::openapi())),
45
45
+
)
46
46
+
.route(
47
47
+
"/api",
48
48
+
axum::routing::get(Html(Scalar::new(ApiDoc::openapi()).to_html())),
42
49
)
43
50
.layer(Extension(pool));
44
51
let listener = tokio::net::TcpListener::bind((host, port)).await?;