pub struct Parameter {
pub name: String,
pub location: ParameterLocation,
pub required: bool,
pub pattern: Option<String>,
pub max_length: Option<u64>,
pub allow_slash: bool,
}Expand description
A single OpenAPI operation parameter.
§The three rule fields (Phase 128, D4(b))
Self::pattern, Self::max_length and Self::allow_slash carry the
DECLARED narrowing for this parameter to the substitution point in
crate::http::HttpClient, where
pmcp::server::schema_validation::validate_path_placeholder reads them through
Parameter::placeholder_rules. They are deliberately NOT feature-gated — they are
plain scalars, they are #[serde(default)], and gating them would make this
struct’s serialized shape feature-dependent, which is a worse break than gating
the accessor that names a feature-gated type.
Fields§
§name: StringParameter name (matches the {name} placeholder for path params).
location: ParameterLocationWhere the parameter is carried in the request.
required: boolWhether the parameter is required.
pattern: Option<String>Declared regular expression the value must match (Phase 128, D4(b)).
NARROWS the unconditional character floor; it never replaces it (D-10).
Populated from [[tools.parameters]] pattern for a curated tool and from a
spec parameter’s own string schema for a spec-driven one.
max_length: Option<u64>Declared maximum length in Unicode code points (Phase 128, D4(b)).
NARROWS the always-on pmcp::server::schema_validation::PLACEHOLDER_MAX_LENGTH
cap; a declared value above that constant cannot widen it (D-08).
allow_slash: boolPermit / inside this parameter’s substituted value (Phase 128, D-11).
The ONLY legitimate source is the server’s own
[[tools.parameters]] allow_slash. A parsed OpenAPI document must never set
it — see Parameter::placeholder_rules and
crate::config::ParamDecl::allow_slash for why.
Implementations§
Source§impl Parameter
impl Parameter
Sourcepub fn new(
name: impl Into<String>,
location: ParameterLocation,
required: bool,
) -> Self
pub fn new( name: impl Into<String>, location: ParameterLocation, required: bool, ) -> Self
Construct a parameter (test/parser convenience).
The Phase 128 rule fields default to “no declared narrowing”, so every
pre-Phase-128 call site keeps compiling unchanged and gets the
unconditional floor plus the always-on cap. Attach declared rules with
Self::with_rules.
Sourcepub fn with_rules(
self,
pattern: Option<String>,
max_length: Option<u64>,
allow_slash: bool,
) -> Self
pub fn with_rules( self, pattern: Option<String>, max_length: Option<u64>, allow_slash: bool, ) -> Self
Attach the declared placeholder rules (Phase 128, D4(b)).
A consuming builder rather than three setters, so the three values that travel together are set together.
Sourcepub fn placeholder_rules(&self) -> PlaceholderRules<'_>
pub fn placeholder_rules(&self) -> PlaceholderRules<'_>
This parameter’s declared rules as a
pmcp::server::schema_validation::PlaceholderRules (Phase 128, D4(b)).
§D-10 — the returned rules NARROW, they never replace
validate_path_placeholder applies its unconditional character floor and
its always-on length cap FIRST and consults these rules afterwards, so a
permissive declared pattern such as ^.*$ cannot switch the injection
check off. A declared max_length above PLACEHOLDER_MAX_LENGTH likewise
cannot widen the constant.
§D-11 — allow_slash is config-only
The returned allow_slash comes from the server’s own
[[tools.parameters]] declaration and from nowhere else. An OpenAPI
document’s reserved-expansion keyword must NEVER be wired to it: a spec is
third-party content baked into a package, that keyword describes
percent-encoding latitude in the spec author’s serialization rules rather
than permission to restructure the request target, and it is widely
copy-pasted without intent. The parser in this module therefore leaves
allow_slash false unconditionally.
§The curated template parser recognizes WHOLE-SEGMENT placeholders only
On the curated single-call surface a placeholder is a whole /-delimited
segment: crate::config::path_placeholder_names matches {name} spanning
an entire segment and nothing else. So /search/{a}{b} is NOT two
placeholders (it parses as the single name a}{b) and /prefix-{id} is not
recognized as carrying a placeholder at all. Attaching rules to a
Parameter does not change that parse. Both shapes are refused at CONFIG
time by crate::config::ServerConfig::validate, so neither can reach
runtime from a [[tools]] declaration — but a spec-derived operation is not
config-validated, which is why the composed-path check at the tail of
substitution is what closes a residual {/} there.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Parameter
impl<'de> Deserialize<'de> for Parameter
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Parameter
impl RefUnwindSafe for Parameter
impl Send for Parameter
impl Sync for Parameter
impl Unpin for Parameter
impl UnsafeUnpin for Parameter
impl UnwindSafe for Parameter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more