refactor(schema): simplify validation and OpenAPI generation (#2709)

This commit is contained in:
Hampus
2026-09-11 23:24:26 +02:00
committed by GitHub
parent 4bc5593f9f
commit de1fd95a99
510 changed files with 29494 additions and 36131 deletions
+1
View File
@@ -118,6 +118,7 @@ WORKDIR /usr/src/app
COPY Cargo.lock ./
COPY fluxer_common/ fluxer_common/
COPY fluxer_app_proxy/ fluxer_app_proxy/
COPY packages/constants/src/AgeGeos.json packages/constants/src/AgeGeos.json
RUN printf '%s\n' \
'[workspace]' \
+24 -7
View File
@@ -2,6 +2,28 @@
use crate::config::AppProxyConfig;
use fluxer_common::geoip::{GeoipConfig, GeoipLookup, GeoipResolver};
use serde::{Deserialize, Serialize};
use std::sync::LazyLock;
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
struct GeoEntry {
country_code: String,
region_code: Option<String>,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
struct AgeGeos {
age_restricted_geos: Vec<GeoEntry>,
age_blocked_geos: Vec<GeoEntry>,
}
static AGE_GEOS: LazyLock<AgeGeos> = LazyLock::new(|| {
serde_json::from_str(include_str!("../../packages/constants/src/AgeGeos.json")).expect(
"bundled packages/constants/src/AgeGeos.json must contain a valid age geography policy",
)
});
pub fn resolver_from_app_config(config: &AppProxyConfig) -> GeoipResolver {
GeoipResolver::from_config(&GeoipConfig {
@@ -18,12 +40,7 @@ pub fn build_geoip_response(lookup: GeoipLookup) -> serde_json::Value {
"regionCode": lookup.region_code,
"latitude": lookup.latitude.map(|v| v.to_string()),
"longitude": lookup.longitude.map(|v| v.to_string()),
"ageRestrictedGeos": [
{"countryCode": "GB", "regionCode": null},
{"countryCode": "BR", "regionCode": null}
],
"ageBlockedGeos": [
{"countryCode": "US", "regionCode": "MS"}
]
"ageRestrictedGeos": &AGE_GEOS.age_restricted_geos,
"ageBlockedGeos": &AGE_GEOS.age_blocked_geos,
})
}