From b662dc9f36fe19aa533116085fbab718742c0894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Greinhofer?= Date: Mon, 9 Dec 2024 08:30:13 -0600 Subject: [PATCH] Fix Decimal format (#166) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the representation of Decimals in the OAS. Signed-off-by: Rémy Greinhofer --- bnaclient/src/lib.rs | 37 ++++++++++++------- lambdas/requests.rest | 15 ++++---- lambdas/src/core/resource/ratings/endpoint.rs | 2 + openapi.yaml | 12 ++++-- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/bnaclient/src/lib.rs b/bnaclient/src/lib.rs index 720d77b..3ca1b27 100644 --- a/bnaclient/src/lib.rs +++ b/bnaclient/src/lib.rs @@ -53,12 +53,13 @@ pub mod types { /// "cost": { /// "description": "Cost of an analysis in USD", /// "examples": [ - /// 6.8941 + /// "6.8941" /// ], /// "type": [ - /// "number", + /// "string", /// "null" - /// ] + /// ], + /// "format": "decimal" /// }, /// "end_time": { /// "description": "Date and time", @@ -156,7 +157,7 @@ pub mod types { pub struct Analysis { ///Cost of an analysis in USD #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub cost: ::std::option::Option, + pub cost: ::std::option::Option<::std::string::String>, ///Date and time #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub end_time: ::std::option::Option>, @@ -217,7 +218,8 @@ pub mod types { /// "type": [ /// "number", /// "null" - /// ] + /// ], + /// "format": "double" /// }, /// "end_time": { /// "description": "Date and time", @@ -349,7 +351,8 @@ pub mod types { /// "type": [ /// "number", /// "null" - /// ] + /// ], + /// "format": "double" /// }, /// "end_time": { /// "description": "Date and time", @@ -2346,9 +2349,10 @@ pub mod types { /// "per_second": { /// "description": "Cost to run Fargate for 1 second", /// "examples": [ - /// 0.0023 + /// "0.0023" /// ], - /// "type": "number" + /// "type": "string", + /// "format": "decimal" /// } /// } ///} @@ -2361,8 +2365,9 @@ pub mod types { pub created_at: ::std::option::Option>, #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] pub fargate_price_id: ::std::option::Option, + ///Cost to run Fargate for 1 second #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] - pub per_second: ::std::option::Option, + pub per_second: ::std::option::Option<::std::string::String>, } impl From<&FargatePrice> for FargatePrice { @@ -3948,7 +3953,10 @@ pub mod types { pub mod builder { #[derive(Clone, Debug)] pub struct Analysis { - cost: ::std::result::Result<::std::option::Option, ::std::string::String>, + cost: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, end_time: ::std::result::Result< ::std::option::Option>, ::std::string::String, @@ -4004,7 +4012,7 @@ pub mod types { impl Analysis { pub fn cost(mut self, value: T) -> Self where - T: std::convert::TryInto<::std::option::Option>, + T: std::convert::TryInto<::std::option::Option<::std::string::String>>, T::Error: std::fmt::Display, { self.cost = value @@ -6490,7 +6498,10 @@ pub mod types { >, fargate_price_id: ::std::result::Result<::std::option::Option, ::std::string::String>, - per_second: ::std::result::Result<::std::option::Option, ::std::string::String>, + per_second: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, } impl Default for FargatePrice { @@ -6531,7 +6542,7 @@ pub mod types { } pub fn per_second(mut self, value: T) -> Self where - T: std::convert::TryInto<::std::option::Option>, + T: std::convert::TryInto<::std::option::Option<::std::string::String>>, T::Error: std::fmt::Display, { self.per_second = value diff --git a/lambdas/requests.rest b/lambdas/requests.rest index 9b25a94..bb3399a 100644 --- a/lambdas/requests.rest +++ b/lambdas/requests.rest @@ -47,6 +47,10 @@ GET {{host}}/cities/submissions?status=Pending # Query a specific submission. GET {{host}}/cities/submissions/1 +### +# Query Fargate prices. +GET {{host}}/prices/fargate + ### # Create a new submission. POST {{host}}/cities/submissions @@ -154,13 +158,10 @@ content-type: application/json Authorization: Bearer {{cognito_access}} { - "state": "Analysis", - "state_machine_id": {{state_machine_id}}, - "scheduled_trigger_id": "04ca18b9-6e0c-1aa5-2c3f-d4b445f840bc", - "sqs_message": "{\"city\": \"Valetta\", \"country\": \"Malta\"}", - "neon_branch_id": null, - "fargate_task_id": null, - "s3_bucket": null + "cost": 10.345, + "start_time": "2024-12-09T14:16:11.133641Z", + "state_machine_id": "804594ed-b3a6-4138-a9d3-454a0578e5f7", + "step": "Setup" } ### Query the BNA analysis performed by the Brokenspoke-analyzer pipeline. diff --git a/lambdas/src/core/resource/ratings/endpoint.rs b/lambdas/src/core/resource/ratings/endpoint.rs index 39fa00f..dea4bc9 100644 --- a/lambdas/src/core/resource/ratings/endpoint.rs +++ b/lambdas/src/core/resource/ratings/endpoint.rs @@ -8,6 +8,7 @@ use super::{ }; use crate::{Context, ExecutionError}; use axum::{ + debug_handler, extract::{Path, Query}, http::StatusCode, response::IntoResponse, @@ -90,6 +91,7 @@ async fn get_ratings_analysis( .map(Json) } +#[debug_handler] async fn post_ratings_analysis( Json(bna_pipeline): Json, ) -> Result<(StatusCode, Json), ExecutionError> { diff --git a/openapi.yaml b/openapi.yaml index 0ef0ffe..dc7158b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -405,9 +405,10 @@ components: type: object properties: cost: - type: number + type: string + format: decimal description: "Cost of an analysis in USD" - example: 6.8941 + example: "6.8941" nullable: true end_time: type: string @@ -466,6 +467,7 @@ components: properties: cost: type: number + format: double description: "Cost of an analysis in USD" example: 6.8941 nullable: true @@ -513,6 +515,7 @@ components: properties: cost: type: number + format: double description: "Cost of an analysis in USD" example: 6.8941 nullable: true @@ -1370,9 +1373,10 @@ components: run. example: 1 per_second: - type: number + type: string + format: decimal description: Cost to run Fargate for 1 second - example: 0.0023 + example: "0.0023" created_at: type: string format: date-time