fix: go back to 2.1.0 format
This commit is contained in:
parent
65257b7e34
commit
048ee833f0
2 changed files with 16 additions and 12 deletions
|
@ -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<RequestClass> {
|
||||
let mut reqs = Vec::new();
|
||||
|
@ -14,12 +14,17 @@ pub fn requests(root: Items) -> Vec<RequestClass> {
|
|||
|
||||
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,
|
||||
}
|
||||
),
|
||||
}
|
||||
|
|
15
src/main.rs
15
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<dyn std::error::Error>> {
|
|||
|
||||
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<dyn std::error::Error>> {
|
|||
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!(" │");
|
||||
|
|
Loading…
Reference in a new issue