From 048ee833f03fd2934cb245a4aa276ba90b524923 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 8 Jun 2023 12:03:43 +0200 Subject: [PATCH] fix: go back to 2.1.0 format --- src/collector.rs | 13 +++++++++---- src/main.rs | 15 +++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/collector.rs b/src/collector.rs index cbbf317..e50a807 100644 --- a/src/collector.rs +++ b/src/collector.rs @@ -1,5 +1,5 @@ use std::str::FromStr; -use postman_collection::v2_0_0::{Spec, RequestClass, Items, Url, UrlClass, HeaderUnion, Body}; +use postman_collection::v2_1_0::{Spec, RequestClass, Items, Url, UrlClass, HeaderUnion, Body}; pub fn collect(collection: Spec) -> Vec { let mut reqs = Vec::new(); @@ -14,12 +14,17 @@ pub fn requests(root: Items) -> Vec { if let Some(r) = root.request { match r { - postman_collection::v2_0_0::RequestUnion::RequestClass(x) => reqs.push(x), - postman_collection::v2_0_0::RequestUnion::String(url) => reqs.push( + postman_collection::v2_1_0::RequestUnion::RequestClass(x) => reqs.push(x), + postman_collection::v2_1_0::RequestUnion::String(url) => reqs.push( RequestClass { method: Some("GET".into()), url: Some(Url::String(url)), - ..Default::default() + auth: None, + body: None, + certificate: None, + description: None, + header: None, + proxy: None, } ), } diff --git a/src/main.rs b/src/main.rs index e2825bd..d190582 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,9 +3,8 @@ mod collector; use clap::{Parser, Subcommand}; -use reqwest::Method; -use postman_collection::{PostmanCollection, v2_0_0::Spec}; +use postman_collection::{PostmanCollection, v2_1_0::Spec}; use crate::collector::{collect, url, send}; // use crate::proto::{Item, Request, Header}; @@ -63,13 +62,13 @@ async fn main() -> Result<(), Box> { let collection = match postman_collection::from_path(args.collection) { - Ok(PostmanCollection::V2_0_0(spec)) => spec, + Ok(PostmanCollection::V2_1_0(spec)) => spec, Ok(PostmanCollection::V1_0_0(_)) => { - eprintln!("collection using v1.0.0 format! only 2.0.0 is allowed"); + eprintln!("collection using v1.0.0 format! only 2.1.0 is allowed"); Spec::default() }, - Ok(PostmanCollection::V2_1_0(_)) => { - eprintln!("collection using v2.1.0 format! only 2.0.0 is allowed"); + Ok(PostmanCollection::V2_0_0(_)) => { + eprintln!("collection using v2.0.0 format! only 2.1.0 is allowed"); Spec::default() }, Err(e) => { @@ -82,11 +81,11 @@ async fn main() -> Result<(), Box> { println!("╶┐ * {}", collection.info.name); if let Some(descr) = &collection.info.description { match descr { - postman_collection::v2_0_0::DescriptionUnion::Description(x) => { + postman_collection::v2_1_0::DescriptionUnion::Description(x) => { if let Some(d) = &x.content { println!(" │ {}", d) }; if let Some(v) = &x.version { println!(" │ {}", v) }; }, - postman_collection::v2_0_0::DescriptionUnion::String(x) => println!(" │ {}", x), + postman_collection::v2_1_0::DescriptionUnion::String(x) => println!(" │ {}", x), } } println!(" │");