From f145e8b76c1554321514d90f8da25fb0690ca613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Greinhofer?= Date: Sat, 9 Nov 2024 12:37:03 -0600 Subject: [PATCH] Fix OpenAPI Specification (#155) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the specification by adding the security scheme to be able to use the JWT token provided by AWS Cocgnito to authenticate the API requests. Signed-off-by: Rémy Greinhofer --- .gitignore | 1 + bnaclient/Cargo.toml | 12 +- bnaclient/src/lib.rs | 467 +++++++++++++++++++++++-------------------- openapi.yaml | 202 ++++++------------- 4 files changed, 318 insertions(+), 364 deletions(-) diff --git a/.gitignore b/.gitignore index 01787b8..f576adf 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ debug/ lambdas/.env lambdas/tests/.hypothesis lambdas/tests/.venv +specs/ target/ diff --git a/bnaclient/Cargo.toml b/bnaclient/Cargo.toml index 6ee844e..7d4b990 100644 --- a/bnaclient/Cargo.toml +++ b/bnaclient/Cargo.toml @@ -3,20 +3,14 @@ name = "bnaclient" version = "1.0.0" edition = "2021" license = "MIT" -description = "Autogenerated API client for the BNA API." -readme = "README.md" -repository = "https://github.com/PeopleForBikes/bna-api/tree/main/bnaclient" [dependencies] - bytes = "1.0" +chrono = { workspace = true, features = ["serde"] } futures-core = "0.3" percent-encoding = "2.3" -reqwest = { workspace = true, default-features = false, features = [ - "json", - "stream", -] } +reqwest = { workspace = true, features = ["json", "stream"] } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } serde_urlencoded = "0.7" -uuid = { workspace = true } +uuid = { workspace = true, features = ["serde", "v4"] } diff --git a/bnaclient/src/lib.rs b/bnaclient/src/lib.rs index 169a7de..2e75c2b 100644 --- a/bnaclient/src/lib.rs +++ b/bnaclient/src/lib.rs @@ -65,26 +65,11 @@ pub mod types { /// }, /// "end_time": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], /// "type": [ - /// "array", + /// "string", /// "null" /// ], - /// "items": { - /// "type": "integer" - /// } + /// "format": "date-time" /// }, /// "fargate_task_arn": { /// "description": "The ARN of the Fargate task that performed the @@ -129,26 +114,11 @@ pub mod types { /// }, /// "start_time": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], /// "type": [ - /// "array", + /// "string", /// "null" /// ], - /// "items": { - /// "type": "integer" - /// } + /// "format": "date-time" /// }, /// "state_machine_id": { /// "$ref": "#/components/schemas/state_machine_id" @@ -175,7 +145,7 @@ pub mod types { pub cost: Option, ///Date and time #[serde(default, skip_serializing_if = "Option::is_none")] - pub end_time: Option>, + pub end_time: Option>, ///The ARN of the Fargate task that performed the analysis #[serde(default, skip_serializing_if = "Option::is_none")] pub fargate_task_arn: Option, @@ -189,7 +159,7 @@ pub mod types { pub sqs_message: Option, ///Date and time #[serde(default, skip_serializing_if = "Option::is_none")] - pub start_time: Option>, + pub start_time: Option>, pub state_machine_id: StateMachineId, #[serde(default, skip_serializing_if = "Option::is_none")] pub step: Option, @@ -231,26 +201,11 @@ pub mod types { /// }, /// "end_time": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], /// "type": [ - /// "array", + /// "string", /// "null" /// ], - /// "items": { - /// "type": "integer" - /// } + /// "format": "date-time" /// }, /// "fargate_task_arn": { /// "description": "The ARN of the Fargate task that performed the @@ -295,26 +250,11 @@ pub mod types { /// }, /// "start_time": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], /// "type": [ - /// "array", + /// "string", /// "null" /// ], - /// "items": { - /// "type": "integer" - /// } + /// "format": "date-time" /// }, /// "step": { /// "$ref": "#/components/schemas/step" @@ -338,7 +278,7 @@ pub mod types { pub cost: Option, ///Date and time #[serde(default, skip_serializing_if = "Option::is_none")] - pub end_time: Option>, + pub end_time: Option>, ///The ARN of the Fargate task that performed the analysis #[serde(default, skip_serializing_if = "Option::is_none")] pub fargate_task_arn: Option, @@ -352,7 +292,7 @@ pub mod types { pub sqs_message: Option, ///Date and time #[serde(default, skip_serializing_if = "Option::is_none")] - pub start_time: Option>, + pub start_time: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] pub step: Option, ///Flag indicating wether the resources were torn down or not at the @@ -393,26 +333,16 @@ pub mod types { /// }, /// "end_time": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], /// "type": [ - /// "array", + /// "string", /// "null" /// ], - /// "items": { - /// "type": "integer" - /// } + /// "format": "date-time" + /// }, + /// "fargate_price_id": { + /// "description": "Identifier of the Fargate Price rate used to + /// compute the cost of the pipeline run.\n", + /// "type": "number" /// }, /// "fargate_task_arn": { /// "description": "The ARN of the Fargate task that performed the @@ -455,6 +385,29 @@ pub mod types { /// "null" /// ] /// }, + /// "start_time": { + /// "description": "Date and time", + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "date-time" + /// }, + /// "state_machine_id": { + /// "$ref": "#/components/schemas/state_machine_id" + /// }, + /// "status": { + /// "description": "", + /// "examples": [ + /// "Pending" + /// ], + /// "type": "string", + /// "enum": [ + /// "Complete", + /// "Pending", + /// "InProgress" + /// ] + /// }, /// "step": { /// "$ref": "#/components/schemas/step" /// }, @@ -477,7 +430,9 @@ pub mod types { pub cost: Option, ///Date and time #[serde(default, skip_serializing_if = "Option::is_none")] - pub end_time: Option>, + pub end_time: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub fargate_price_id: Option, ///The ARN of the Fargate task that performed the analysis #[serde(default, skip_serializing_if = "Option::is_none")] pub fargate_task_arn: Option, @@ -489,6 +444,14 @@ pub mod types { ///Copy of the JSON message that was sent for processing #[serde(default, skip_serializing_if = "Option::is_none")] pub sqs_message: Option, + ///Date and time + #[serde(default, skip_serializing_if = "Option::is_none")] + pub start_time: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub state_machine_id: Option, + /// + #[serde(default, skip_serializing_if = "Option::is_none")] + pub status: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub step: Option, ///Flag indicating wether the resources were torn down or not at the @@ -509,6 +472,92 @@ pub mod types { } } + /// + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "", + /// "examples": [ + /// "Pending" + /// ], + /// "type": "string", + /// "enum": [ + /// "Complete", + /// "Pending", + /// "InProgress" + /// ] + ///} + /// ``` + ///
+ #[derive( + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde :: Deserialize, + serde :: Serialize, + )] + pub enum AnalysisPostStatus { + Complete, + Pending, + InProgress, + } + + impl From<&AnalysisPostStatus> for AnalysisPostStatus { + fn from(value: &AnalysisPostStatus) -> Self { + value.clone() + } + } + + impl ToString for AnalysisPostStatus { + fn to_string(&self) -> String { + match *self { + Self::Complete => "Complete".to_string(), + Self::Pending => "Pending".to_string(), + Self::InProgress => "InProgress".to_string(), + } + } + } + + impl std::str::FromStr for AnalysisPostStatus { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { + match value { + "Complete" => Ok(Self::Complete), + "Pending" => Ok(Self::Pending), + "InProgress" => Ok(Self::InProgress), + _ => Err("invalid value".into()), + } + } + } + + impl std::convert::TryFrom<&str> for AnalysisPostStatus { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for AnalysisPostStatus { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom for AnalysisPostStatus { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { + value.parse() + } + } + ///API Gateway ID associated with the request /// ///
JSON schema @@ -1020,23 +1069,8 @@ pub mod types { /// }, /// "created_at": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], - /// "type": "array", - /// "items": { - /// "type": "integer" - /// } + /// "type": "string", + /// "format": "date-time" /// }, /// "rating_id": { /// "description": "Analysis identifier", @@ -1069,8 +1103,8 @@ pub mod types { ///City identifier pub city_id: uuid::Uuid, ///Date and time - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub created_at: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub created_at: Option>, ///Analysis identifier pub rating_id: uuid::Uuid, pub score: f64, @@ -1159,8 +1193,8 @@ pub mod types { pub city_id: uuid::Uuid, #[serde(default, skip_serializing_if = "Option::is_none")] pub country: Option, - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub created_at: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub created_at: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] pub latitude: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -1184,8 +1218,8 @@ pub mod types { #[serde(default, skip_serializing_if = "Option::is_none")] pub state_abbrev: Option, ///Date and time - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub updated_at: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub updated_at: Option>, ///Analysis version. The format follows the [calver](https://calver.org) specification with the YY.0M[.Minor] scheme. pub version: String, } @@ -1227,23 +1261,8 @@ pub mod types { /// }, /// "created_at": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], - /// "type": "array", - /// "items": { - /// "type": "integer" - /// } + /// "type": "string", + /// "format": "date-time" /// }, /// "fips_code": { /// "description": "Numerical city identifier given by the U.S. census, @@ -1285,8 +1304,8 @@ pub mod types { #[serde(default, skip_serializing_if = "Option::is_none")] pub city_id: Option, ///Date and time - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub created_at: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub created_at: Option>, ///Numerical city identifier given by the U.S. census, or 0 for non-US /// cities #[serde(default, skip_serializing_if = "Option::is_none")] @@ -1394,23 +1413,8 @@ pub mod types { /// }, /// "created_at": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], - /// "type": "array", - /// "items": { - /// "type": "integer" - /// } + /// "type": "string", + /// "format": "date-time" /// }, /// "latitude": { /// "description": "Geographic coordinate that specifies the @@ -1468,23 +1472,8 @@ pub mod types { /// }, /// "updated_at": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], - /// "type": "array", - /// "items": { - /// "type": "integer" - /// } + /// "type": "string", + /// "format": "date-time" /// } /// } ///} @@ -1498,8 +1487,8 @@ pub mod types { #[serde(default, skip_serializing_if = "Option::is_none")] pub country: Option, ///Date and time - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub created_at: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub created_at: Option>, #[serde(default, skip_serializing_if = "Option::is_none")] pub latitude: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -1520,8 +1509,8 @@ pub mod types { #[serde(default, skip_serializing_if = "Option::is_none")] pub state_abbrev: Option, ///Date and time - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub updated_at: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub updated_at: Option>, } impl From<&City> for City { @@ -3168,30 +3157,18 @@ pub mod types { /// "examples": [ /// true /// ], - /// "type": "boolean" + /// "type": [ + /// "boolean", + /// "null" + /// ] /// }, /// "country": { /// "$ref": "#/components/schemas/country" /// }, /// "created_at": { /// "description": "Date and time", - /// "examples": [ - /// [ - /// 2023, - /// 6, - /// 16, - /// 22, - /// 0, - /// 0, - /// 0, - /// 0, - /// 0 - /// ] - /// ], - /// "type": "array", - /// "items": { - /// "type": "integer" - /// } + /// "type": "string", + /// "format": "date-time" /// }, /// "email": { /// "description": "Email address", @@ -3274,8 +3251,8 @@ pub mod types { #[serde(default, skip_serializing_if = "Option::is_none")] pub country: Option, ///Date and time - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub created_at: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub created_at: Option>, ///Email address #[serde(default, skip_serializing_if = "Option::is_none")] pub email: Option, @@ -3718,12 +3695,12 @@ pub mod types { #[derive(Clone, Debug)] pub struct Analysis { cost: Result, String>, - end_time: Result>, String>, + end_time: Result>, String>, fargate_task_arn: Result, String>, results_posted: Result, String>, s3_bucket: Result, String>, sqs_message: Result, String>, - start_time: Result>, String>, + start_time: Result>, String>, state_machine_id: Result, step: Result, String>, torn_down: Result, String>, @@ -3759,7 +3736,7 @@ pub mod types { } pub fn end_time(mut self, value: T) -> Self where - T: std::convert::TryInto>>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.end_time = value @@ -3812,7 +3789,7 @@ pub mod types { } pub fn start_time(mut self, value: T) -> Self where - T: std::convert::TryInto>>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.start_time = value @@ -3893,12 +3870,12 @@ pub mod types { #[derive(Clone, Debug)] pub struct AnalysisPatch { cost: Result, String>, - end_time: Result>, String>, + end_time: Result>, String>, fargate_task_arn: Result, String>, results_posted: Result, String>, s3_bucket: Result, String>, sqs_message: Result, String>, - start_time: Result>, String>, + start_time: Result>, String>, step: Result, String>, torn_down: Result, String>, } @@ -3932,7 +3909,7 @@ pub mod types { } pub fn end_time(mut self, value: T) -> Self where - T: std::convert::TryInto>>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.end_time = value @@ -3985,7 +3962,7 @@ pub mod types { } pub fn start_time(mut self, value: T) -> Self where - T: std::convert::TryInto>>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.start_time = value @@ -4051,11 +4028,15 @@ pub mod types { #[derive(Clone, Debug)] pub struct AnalysisPost { cost: Result, String>, - end_time: Result>, String>, + end_time: Result>, String>, + fargate_price_id: Result, String>, fargate_task_arn: Result, String>, result_posted: Result, String>, s3_bucket: Result, String>, sqs_message: Result, String>, + start_time: Result>, String>, + state_machine_id: Result, String>, + status: Result, String>, step: Result, String>, torn_down: Result, String>, } @@ -4065,10 +4046,14 @@ pub mod types { Self { cost: Ok(Default::default()), end_time: Ok(Default::default()), + fargate_price_id: Ok(Default::default()), fargate_task_arn: Ok(Default::default()), result_posted: Ok(Default::default()), s3_bucket: Ok(Default::default()), sqs_message: Ok(Default::default()), + start_time: Ok(Default::default()), + state_machine_id: Ok(Default::default()), + status: Ok(Default::default()), step: Ok(Default::default()), torn_down: Ok(Default::default()), } @@ -4088,7 +4073,7 @@ pub mod types { } pub fn end_time(mut self, value: T) -> Self where - T: std::convert::TryInto>>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.end_time = value @@ -4096,6 +4081,19 @@ pub mod types { .map_err(|e| format!("error converting supplied value for end_time: {}", e)); self } + pub fn fargate_price_id(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.fargate_price_id = value.try_into().map_err(|e| { + format!( + "error converting supplied value for fargate_price_id: {}", + e + ) + }); + self + } pub fn fargate_task_arn(mut self, value: T) -> Self where T: std::convert::TryInto>, @@ -4139,6 +4137,39 @@ pub mod types { .map_err(|e| format!("error converting supplied value for sqs_message: {}", e)); self } + pub fn start_time(mut self, value: T) -> Self + where + T: std::convert::TryInto>>, + T::Error: std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + pub fn state_machine_id(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.state_machine_id = value.try_into().map_err(|e| { + format!( + "error converting supplied value for state_machine_id: {}", + e + ) + }); + self + } + pub fn status(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } pub fn step(mut self, value: T) -> Self where T: std::convert::TryInto>, @@ -4167,10 +4198,14 @@ pub mod types { Ok(Self { cost: value.cost?, end_time: value.end_time?, + fargate_price_id: value.fargate_price_id?, fargate_task_arn: value.fargate_task_arn?, result_posted: value.result_posted?, s3_bucket: value.s3_bucket?, sqs_message: value.sqs_message?, + start_time: value.start_time?, + state_machine_id: value.state_machine_id?, + status: value.status?, step: value.step?, torn_down: value.torn_down?, }) @@ -4182,10 +4217,14 @@ pub mod types { Self { cost: Ok(value.cost), end_time: Ok(value.end_time), + fargate_price_id: Ok(value.fargate_price_id), fargate_task_arn: Ok(value.fargate_task_arn), result_posted: Ok(value.result_posted), s3_bucket: Ok(value.s3_bucket), sqs_message: Ok(value.sqs_message), + start_time: Ok(value.start_time), + state_machine_id: Ok(value.state_machine_id), + status: Ok(value.status), step: Ok(value.step), torn_down: Ok(value.torn_down), } @@ -4756,7 +4795,7 @@ pub mod types { #[derive(Clone, Debug)] pub struct BnaSummary { city_id: Result, - created_at: Result, String>, + created_at: Result>, String>, rating_id: Result, score: Result, version: Result, @@ -4787,7 +4826,7 @@ pub mod types { } pub fn created_at(mut self, value: T) -> Self where - T: std::convert::TryInto>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.created_at = value @@ -4856,7 +4895,7 @@ pub mod types { pub struct BnaSummaryWithCityItem { city_id: Result, country: Result, String>, - created_at: Result, String>, + created_at: Result>, String>, latitude: Result, String>, longitude: Result, String>, name: Result, String>, @@ -4866,7 +4905,7 @@ pub mod types { speed_limit: Result, String>, state: Result, String>, state_abbrev: Result, String>, - updated_at: Result, String>, + updated_at: Result>, String>, version: Result, } @@ -4914,7 +4953,7 @@ pub mod types { } pub fn created_at(mut self, value: T) -> Self where - T: std::convert::TryInto>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.created_at = value @@ -5014,7 +5053,7 @@ pub mod types { } pub fn updated_at(mut self, value: T) -> Self where - T: std::convert::TryInto>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.updated_at = value @@ -5083,7 +5122,7 @@ pub mod types { pub struct Census { census_id: Result, String>, city_id: Result, String>, - created_at: Result, String>, + created_at: Result>, String>, fips_code: Result, String>, pop_size: Result, String>, population: Result, String>, @@ -5125,7 +5164,7 @@ pub mod types { } pub fn created_at(mut self, value: T) -> Self where - T: std::convert::TryInto>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.created_at = value @@ -5196,7 +5235,7 @@ pub mod types { pub struct City { city_id: Result, String>, country: Result, String>, - created_at: Result, String>, + created_at: Result>, String>, latitude: Result, String>, longitude: Result, String>, name: Result, String>, @@ -5204,7 +5243,7 @@ pub mod types { speed_limit: Result, String>, state: Result, String>, state_abbrev: Result, String>, - updated_at: Result, String>, + updated_at: Result>, String>, } impl Default for City { @@ -5248,7 +5287,7 @@ pub mod types { } pub fn created_at(mut self, value: T) -> Self where - T: std::convert::TryInto>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.created_at = value @@ -5328,7 +5367,7 @@ pub mod types { } pub fn updated_at(mut self, value: T) -> Self where - T: std::convert::TryInto>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.updated_at = value @@ -6378,7 +6417,7 @@ pub mod types { city: Result, String>, consent: Result, String>, country: Result, String>, - created_at: Result, String>, + created_at: Result>, String>, email: Result, String>, fips_code: Result, String>, first_name: Result, String>, @@ -6443,7 +6482,7 @@ pub mod types { } pub fn created_at(mut self, value: T) -> Self where - T: std::convert::TryInto>, + T: std::convert::TryInto>>, T::Error: std::fmt::Display, { self.created_at = value diff --git a/openapi.yaml b/openapi.yaml index e68893a..1b952cf 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9,6 +9,8 @@ info: servers: - url: "https://api.peopleforbikes.xyz" description: Staging API + - url: "https://localhost:3000" + description: Locol API tags: - name: rating - name: city @@ -44,7 +46,7 @@ paths: 403: $ref: "#/components/responses/forbidden" security: - - Authorizer: [] + - Authorize: [] /ratings/analyses: get: operationId: getRatingsAnalyses @@ -61,7 +63,7 @@ paths: - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/page_size" security: - - Authorizer: [] + - Authorize: [] post: operationId: postRatingsAnalyses summary: Submit a new city to analyze @@ -80,7 +82,7 @@ paths: 400: $ref: "#/components/responses/bad_request" security: - - Authorizer: [] + - Authorize: [] /ratings/analyses/{analysis_id}: get: operationId: getAnalysis @@ -100,7 +102,7 @@ paths: 404: $ref: "#/components/responses/not_found" security: - - Authorizer: [] + - Authorize: [] patch: operationId: patchAnalysis summary: Update an analysis @@ -123,7 +125,7 @@ paths: 404: $ref: "#/components/responses/not_found" security: - - Authorizer: [] + - Authorize: [] parameters: - $ref: "#/components/parameters/analysis_id" /ratings/{rating_id}: @@ -193,7 +195,7 @@ paths: - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/page_size" security: - - Authorizer: [] + - Authorize: [write] /cities/submissions: get: operationId: getCitySubmissions @@ -260,7 +262,7 @@ paths: 404: $ref: "#/components/responses/not_found" security: - - Authorizer: [] + - Authorize: [] parameters: - $ref: "#/components/parameters/submission_id" /cities/{country}/{region}/{name}: @@ -350,7 +352,7 @@ paths: 403: $ref: "#/components/responses/forbidden" security: - - Authorizer: [] + - Authorize: [] components: schemas: analysis: @@ -362,20 +364,9 @@ components: example: 6.8941 nullable: true end_time: - type: array - items: - type: integer + type: string + format: date-time description: "Date and time" - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 nullable: true fargate_task_arn: type: string @@ -399,20 +390,9 @@ components: "fips_code":"3570670"} nullable: true start_time: - type: array + type: string + format: date-time description: "Date and time" - items: - type: integer - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 nullable: true state_machine_id: $ref: "#/components/schemas/state_machine_id" @@ -435,20 +415,9 @@ components: example: 6.8941 nullable: true end_time: - type: array + type: string + format: date-time description: "Date and time" - items: - type: integer - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 nullable: true fargate_task_arn: type: string @@ -472,20 +441,9 @@ components: "fips_code":"3570670"} nullable: true start_time: - type: array + type: string + format: date-time description: "Date and time" - items: - type: integer - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 nullable: true step: $ref: "#/components/schemas/step" @@ -504,20 +462,9 @@ components: example: 6.8941 nullable: true end_time: - type: array + type: string + format: date-time description: "Date and time" - items: - type: integer - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 nullable: true fargate_task_arn: type: string @@ -540,6 +487,11 @@ components: {"country":"United States","city":"santa rosa","region":"new mexico", "fips_code":"3570670"} nullable: true + start_time: + type: string + format: date-time + description: "Date and time" + nullable: true step: $ref: "#/components/schemas/step" torn_down: @@ -548,6 +500,21 @@ components: Flag indicating wether the resources were torn down or not at the end of the analysis nullable: true + state_machine_id: + $ref: "#/components/schemas/state_machine_id" + fargate_price_id: + type: number + description: > + Identifier of the Fargate Price rate used to compute the cost of the pipeline + run. + status: + type: string + enum: + - Complete + - Pending + - InProgress + description: "" + example: "Pending" api_gateway_id: type: string description: "API Gateway ID associated with the request " @@ -729,20 +696,9 @@ components: description: "City identifier" example: "6d1927b4-3474-4ce0-9b2e-2a1f5a7d91bd" created_at: - type: array + type: string + format: date-time description: "Date and time" - items: - type: integer - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 score: type: number description: "BNA score" @@ -778,20 +734,9 @@ components: description: "City identifier" example: "6d1927b4-3474-4ce0-9b2e-2a1f5a7d91bd" created_at: - type: array + type: string + format: date-time description: "Date and time" - items: - type: integer - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 fips_code: type: string description: > @@ -822,20 +767,9 @@ components: country: $ref: "#/components/schemas/country" created_at: - type: array + type: string + format: date-time description: "Date and time" - items: - type: integer - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 latitude: type: number description: > @@ -874,20 +808,9 @@ components: description: "A short version of the state name, usually 2 or 3 character long." example: "VAN" updated_at: - type: array + type: string + format: date-time description: "Date and time" - items: - type: integer - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 city_post: type: object properties: @@ -1177,25 +1100,15 @@ components: example: "Antwerp" consent: type: boolean + nullable: true description: "Consent status" example: true country: $ref: "#/components/schemas/country" created_at: - type: array + type: string + format: date-time description: "Date and time" - items: - type: integer - example: - - 2023 - - 6 - - 16 - - 22 - - 0 - - 0 - - 0 - - 0 - - 0 email: type: string description: Email address @@ -1610,6 +1523,13 @@ components: items: $ref: "#/components/schemas/submission" securitySchemes: - Authorizer: - type: "oauth2" - flows: {} + Authorize: + description: | + Bearer token using a JWT. + + Authenticate against AWS Cognito using the AWS CLI to obtain the token (replace the placeholders): + + `aws cognito-idp initiate-auth --auth-flow USER_PASSWORD_AUTH --client-id --auth-parameters USERNAME=,PASSWORD=` + type: http + scheme: bearer + bearerFormat: JWT