Skip to content

Commit 6710b1d

Browse files
committed
openapi: Add explicit servers declaration
1 parent 6a71a30 commit 6710b1d

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

src/config/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Server {
162162
// the `script` in `public/github-redirect.html`
163163
let content_security_policy = format!(
164164
"default-src 'self'; \
165-
connect-src 'self' *.ingest.sentry.io https://docs.rs https://play.rust-lang.org {cdn_domain}; \
165+
connect-src 'self' https://crates.io https://staging.crates.io *.ingest.sentry.io https://docs.rs https://play.rust-lang.org {cdn_domain}; \
166166
script-src 'self' 'unsafe-eval' 'sha256-n1+BB7Ckjcal1Pr7QNBh/dKRTtBQsIytFodRiIosXdE=' 'sha256-dbf9FMl76C7BnK1CC3eWb3pvsQAUaTYSHAlBy9tNTG0='; \
167167
style-src 'self' 'unsafe-inline' https://code.cdn.mozilla.net; \
168168
font-src https://code.cdn.mozilla.net; \

src/openapi.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ use utoipa::OpenApi;
22
use utoipa_axum::router::OpenApiRouter;
33

44
#[derive(OpenApi)]
5-
#[openapi(info(
6-
title = "crates.io",
7-
description = "API documentation for the [crates.io](https://crates.io/) package registry",
8-
terms_of_service = "https://crates.io/policies",
9-
contact(name = "the crates.io team", email = "[email protected]"),
10-
license(),
11-
version = "0.0.0",
12-
))]
5+
#[openapi(
6+
info(
7+
title = "crates.io",
8+
description = "API documentation for the [crates.io](https://crates.io/) package registry",
9+
terms_of_service = "https://crates.io/policies",
10+
contact(name = "the crates.io team", email = "[email protected]"),
11+
license(),
12+
version = "0.0.0",
13+
),
14+
servers(
15+
(url = "https://crates.io"),
16+
(url = "https://staging.crates.io"),
17+
),
18+
)]
1319
pub struct BaseOpenApi;
1420

1521
impl BaseOpenApi {

src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,13 @@ snapshot_kind: text
1919
"version": "0.0.0"
2020
},
2121
"openapi": "3.1.0",
22-
"paths": {}
22+
"paths": {},
23+
"servers": [
24+
{
25+
"url": "https://crates.io"
26+
},
27+
{
28+
"url": "https://staging.crates.io"
29+
}
30+
]
2331
}

0 commit comments

Comments
 (0)