pub struct OpenApiDiagnostic {
pub kind: DiagnosticKind,
pub pointer: Option<String>,
pub source_preview: Option<String>,
pub context: Option<String>,
pub line: Option<usize>,
}Expand description
Structured diagnostic emitted by the OpenAPI importer. Implements
std::error::Error so it can be stored inside anyhow::Error,
enabling callers to downcast and inspect the structured data instead of
parsing the human-readable error string.
Fields§
§kind: DiagnosticKindMachine-readable classification of the issue.
pointer: Option<String>JSON pointer into the document where the issue was detected.
source_preview: Option<String>A snippet of the document at the pointer location.
context: Option<String>Human-readable context when there is no pointer (e.g. "parameter \foo`“`).
line: Option<usize>Approximate 1-based source line for the node at pointer, when resolvable.
Implementations§
Source§impl OpenApiDiagnostic
impl OpenApiDiagnostic
pub fn from_pointer( kind: DiagnosticKind, pointer: impl Into<String>, source_preview: Option<String>, line: Option<usize>, ) -> Self
pub fn from_named_context( kind: DiagnosticKind, context: impl Into<String>, ) -> Self
pub fn simple(kind: DiagnosticKind) -> Self
Sourcepub fn note(&self) -> Option<&str>
pub fn note(&self) -> Option<&str>
Returns the human-readable note text for this diagnostic, if any.
Sourcepub fn classify(&self) -> (&'static str, String)
pub fn classify(&self) -> (&'static str, String)
Returns the corpus (kind, feature) classification for this diagnostic.
This is the canonical mapping from DiagnosticKind to the string
identifiers used in corpus reports. Keeping it here means adding a new
variant produces a compile error at the definition site.
pub fn unsupported_kind_for_pointer( pointer: Option<&str>, feature: &str, ) -> &'static str
Trait Implementations§
Source§impl Clone for OpenApiDiagnostic
impl Clone for OpenApiDiagnostic
Source§fn clone(&self) -> OpenApiDiagnostic
fn clone(&self) -> OpenApiDiagnostic
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OpenApiDiagnostic
impl Debug for OpenApiDiagnostic
Source§impl Display for OpenApiDiagnostic
impl Display for OpenApiDiagnostic
Source§impl Error for OpenApiDiagnostic
impl Error for OpenApiDiagnostic
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()