oas3 0.2.1

Structures and tools to parse, navigate and validate OpenAPI v3 specifications.
Documentation
use std::cell::Cell;

#[derive(Debug, Clone)]
pub struct ParamReplacement {
    pub name: String,
    pub value: String,
    pub used: Cell<bool>,
}

impl ParamReplacement {
    pub fn new<N, V>(name: N, val: V) -> Self
    where
        N: Into<String>,
        V: Into<String>,
    {
        Self {
            name: name.into(),
            value: val.into(),
            used: Cell::new(false),
        }
    }
}

impl ParamReplacement {
    pub fn used(&self) -> bool {
        self.used.get()
    }
}

#[derive(Debug, Clone, PartialEq)]
pub enum ParamPosition {
    Path,
    Query,
    Cookie,
    Header,
}

#[derive(Debug, Clone)]
pub struct TestParam {
    pub name: String,
    pub value: String,
    pub position: ParamPosition,
}

impl TestParam {
    pub fn new<N, V>(name: N, val: V, pos: ParamPosition) -> Self
    where
        N: Into<String>,
        V: Into<String>,
    {
        Self {
            name: name.into(),
            value: val.into(),
            position: pos,
        }
    }

    pub fn path<N, V>(name: N, val: V) -> Self
    where
        N: Into<String>,
        V: Into<String>,
    {
        Self::new(name, val, ParamPosition::Path)
    }

    pub fn query<N, V>(name: N, val: V) -> Self
    where
        N: Into<String>,
        V: Into<String>,
    {
        Self::new(name, val, ParamPosition::Query)
    }

    pub fn cookie<N, V>(name: N, val: V) -> Self
    where
        N: Into<String>,
        V: Into<String>,
    {
        Self::new(name, val, ParamPosition::Cookie)
    }

    pub fn header<N, V>(name: N, val: V) -> Self
    where
        N: Into<String>,
        V: Into<String>,
    {
        Self::new(name, val, ParamPosition::Header)
    }
}