Skip to content

Commit

Permalink
Merge branch 'main' into base64
Browse files Browse the repository at this point in the history
  • Loading branch information
raimundo-henriques authored Jun 25, 2024
2 parents 0d3d51d + ed98fb6 commit ba83b31
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1,129 deletions.
20 changes: 19 additions & 1 deletion endpoint/src/api_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#![allow(renamed_and_removed_lints)]
#![allow(clippy::blocks_in_conditions)]

use crate::datamodel::{PfId, ProductFootprint};
use chrono::{DateTime, Utc};
use okapi::openapi3::Responses;
use pact_data_model::*;
use rocket::serde::json::Json;
use rocket::{
http::Header,
Expand All @@ -21,6 +21,7 @@ use rocket_okapi::gen::OpenApiGenerator;
use rocket_okapi::response::OpenApiResponderInner;
use rocket_okapi::OpenApiError;
use schemars::JsonSchema;
use uuid::Uuid;

#[derive(FromForm)]
pub(crate) struct FilterString<'r> {
Expand Down Expand Up @@ -111,6 +112,23 @@ pub(crate) struct PFRequestEventBody {
pub(crate) comment: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, JsonSchema, PartialEq)]
#[serde(crate = "rocket::serde", rename_all = "camelCase")]
pub(crate) struct PfIdParam(pub PfId);

impl<'a> rocket::request::FromParam<'a> for PfIdParam {
type Error = UuidError;

fn from_param(param: &'a str) -> Result<Self, Self::Error> {
let uuid = Uuid::parse_str(param).map_err(UuidError::ParseError)?;
if uuid.get_version_num() != 4 {
Err(UuidError::VersionError)
} else {
Ok(PfIdParam(PfId(uuid)))
}
}
}

fn openapi_link_header() -> okapi::openapi3::Header {
okapi::openapi3::Header {
description: Some(
Expand Down
Loading

0 comments on commit ba83b31

Please sign in to comment.