Skip to content

Commit

Permalink
Fix Decimal format (#166)
Browse files Browse the repository at this point in the history
Fixes the representation of Decimals in the OAS.

Signed-off-by: Rémy Greinhofer <[email protected]>
  • Loading branch information
rgreinho authored Dec 9, 2024
1 parent 790006d commit b662dc9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 24 deletions.
37 changes: 24 additions & 13 deletions bnaclient/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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<f64>,
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<chrono::DateTime<chrono::offset::Utc>>,
Expand Down Expand Up @@ -217,7 +218,8 @@ pub mod types {
/// "type": [
/// "number",
/// "null"
/// ]
/// ],
/// "format": "double"
/// },
/// "end_time": {
/// "description": "Date and time",
Expand Down Expand Up @@ -349,7 +351,8 @@ pub mod types {
/// "type": [
/// "number",
/// "null"
/// ]
/// ],
/// "format": "double"
/// },
/// "end_time": {
/// "description": "Date and time",
Expand Down Expand Up @@ -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"
/// }
/// }
///}
Expand All @@ -2361,8 +2365,9 @@ pub mod types {
pub created_at: ::std::option::Option<chrono::DateTime<chrono::offset::Utc>>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub fargate_price_id: ::std::option::Option<f64>,
///Cost to run Fargate for 1 second
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub per_second: ::std::option::Option<f64>,
pub per_second: ::std::option::Option<::std::string::String>,
}

impl From<&FargatePrice> for FargatePrice {
Expand Down Expand Up @@ -3948,7 +3953,10 @@ pub mod types {
pub mod builder {
#[derive(Clone, Debug)]
pub struct Analysis {
cost: ::std::result::Result<::std::option::Option<f64>, ::std::string::String>,
cost: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
end_time: ::std::result::Result<
::std::option::Option<chrono::DateTime<chrono::offset::Utc>>,
::std::string::String,
Expand Down Expand Up @@ -4004,7 +4012,7 @@ pub mod types {
impl Analysis {
pub fn cost<T>(mut self, value: T) -> Self
where
T: std::convert::TryInto<::std::option::Option<f64>>,
T: std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: std::fmt::Display,
{
self.cost = value
Expand Down Expand Up @@ -6490,7 +6498,10 @@ pub mod types {
>,
fargate_price_id:
::std::result::Result<::std::option::Option<f64>, ::std::string::String>,
per_second: ::std::result::Result<::std::option::Option<f64>, ::std::string::String>,
per_second: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}

impl Default for FargatePrice {
Expand Down Expand Up @@ -6531,7 +6542,7 @@ pub mod types {
}
pub fn per_second<T>(mut self, value: T) -> Self
where
T: std::convert::TryInto<::std::option::Option<f64>>,
T: std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: std::fmt::Display,
{
self.per_second = value
Expand Down
15 changes: 8 additions & 7 deletions lambdas/requests.rest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions lambdas/src/core/resource/ratings/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use super::{
};
use crate::{Context, ExecutionError};
use axum::{
debug_handler,
extract::{Path, Query},
http::StatusCode,
response::IntoResponse,
Expand Down Expand Up @@ -90,6 +91,7 @@ async fn get_ratings_analysis(
.map(Json)
}

#[debug_handler]
async fn post_ratings_analysis(
Json(bna_pipeline): Json<BNAPipelinePost>,
) -> Result<(StatusCode, Json<Value>), ExecutionError> {
Expand Down
12 changes: 8 additions & 4 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -466,6 +467,7 @@ components:
properties:
cost:
type: number
format: double
description: "Cost of an analysis in USD"
example: 6.8941
nullable: true
Expand Down Expand Up @@ -513,6 +515,7 @@ components:
properties:
cost:
type: number
format: double
description: "Cost of an analysis in USD"
example: 6.8941
nullable: true
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b662dc9

Please sign in to comment.