paperclip_core/
error.rs

1#[cfg(feature = "v2")]
2use crate::v2::models::{DataType, ParameterIn};
3use thiserror::Error;
4
5/// Errors related to spec validation.
6#[derive(Debug, Error)]
7pub enum ValidationError {
8    /// Failed to resolve the schema because an invalid URI was provided for
9    /// `$ref` field.
10    ///
11    /// Currently, we only support `#/{definitions,parameters}/Name` in `$ref` field.
12    #[error("Invalid $ref URI {:?}. Only relative URIs are supported.", _0)]
13    InvalidRefUri(String),
14    /// The specified reference is missing in the spec.
15    #[error("Reference missing in spec: {}", _0)]
16    MissingReference(String),
17    /// If a parameter specifies body, then schema must be specified.
18    #[error(
19        "Parameter {:?} in path {:?} is a body but the schema is missing",
20        _0,
21        _1
22    )]
23    MissingSchemaForBodyParameter(String, String),
24    /// Some headers have special meaning in OpenAPI. The user cannot have these headers
25    /// in their API spec.
26    #[error("Path {:?} has header parameter {:?} which is not allowed", _1, _0)]
27    InvalidHeader(String, String),
28    #[cfg(feature = "v2")]
29    /// Only arrays and primitive types are allowed in parameters.
30    #[error(
31        "Parameter {:?} in path {:?} has specified {:?} type, but it's invalid for {:?} parameters",
32        _0,
33        _1,
34        _2,
35        _3
36    )]
37    InvalidParameterType(String, String, Option<DataType>, ParameterIn),
38}