From 84f683c264455decb61191b087a0a60a425f65a9 Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Tue, 15 Oct 2024 15:04:12 +0100 Subject: [PATCH 1/2] Fix duplicate protocol in export api --- thoth-export-server/src/lib.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/thoth-export-server/src/lib.rs b/thoth-export-server/src/lib.rs index 7ac5ca87d..187770eac 100644 --- a/thoth-export-server/src/lib.rs +++ b/thoth-export-server/src/lib.rs @@ -4,7 +4,7 @@ use std::time::Duration; use actix_cors::Cors; use actix_web::{middleware::Logger, web::Data, App, HttpServer}; use paperclip::actix::{web, web::HttpResponse, OpenApiExt}; -use paperclip::v2::models::{Contact, DefaultApiRaw, Info, License, Tag}; +use paperclip::v2::models::{Contact, DefaultApiRaw, Info, License, OperationProtocol, Tag}; use thoth_client::ThothClient; mod bibtex; @@ -56,8 +56,20 @@ pub async fn start_server( log::info!("Setting Thoth GraphQL endpoint to {}", gql_endpoint); HttpServer::new(move || { + // extract hostname and protocol from public URL + let (protocol, host) = public_url + .strip_prefix("https://") + .map(|stripped| (OperationProtocol::Https, stripped)) + .or_else(|| { + public_url + .strip_prefix("http://") + .map(|stripped| (OperationProtocol::Http, stripped)) + }) + .unwrap_or((OperationProtocol::Http, public_url.as_str())); + let spec = DefaultApiRaw { - host: Some(public_url.clone()), + host: Some(host.to_string()), + schemes: [protocol].into_iter().collect(), tags: vec![ Tag { name: "Formats".to_string(), From 9bb0dd06f5e88e7acbddd093e356a1fc976ba023 Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Tue, 15 Oct 2024 15:05:57 +0100 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb93c631b..eecc30b0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed + - [636](https://github.com/thoth-pub/thoth/issues/636) - OpenAPI documentation was displaying the public URL of the export API with an extra protocol ## [[0.12.11]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.11) - 2024-10-14 ### Changed