#[non_exhaustive]pub enum Error {
Show 31 variants
ReadSpec {
path: String,
source: Error,
},
ParseSpec {
path: String,
source: Error,
},
ReadRefFile {
file: String,
source: Error,
},
ParseRefFile {
file: String,
source: Error,
},
ReadConfig {
path: String,
source: Error,
},
ParseConfig {
path: String,
source: Error,
},
Unimplemented(String),
WriteOutput {
path: String,
source: Error,
},
ReadOutput {
path: String,
source: Error,
},
UnsupportedSpecVersion {
document: String,
version: String,
hint: String,
},
UnsupportedSpecKey {
key: String,
reason: String,
hint: String,
},
UnresolvedRef(String),
UnsupportedRef {
reference: String,
reason: String,
},
InvalidExtensionValue {
key: String,
at: String,
expected: String,
found: String,
},
UnsupportedSchema {
path: String,
reason: String,
},
SchemaDepthExceeded {
path: String,
limit: usize,
},
UnsupportedOperation {
method: String,
path: String,
reason: String,
},
UnsupportedContentType {
method: String,
path: String,
location: String,
declared: String,
hint: String,
},
UnsupportedDefault {
owner: String,
property: String,
declared: String,
hint: String,
},
InvalidPathParameter {
method: String,
path: String,
name: String,
},
UndeclaredPathParameter {
method: String,
path: String,
name: String,
},
TypeNameCollision {
name: String,
artifact: String,
hint: String,
},
PreludeShadowing {
name: String,
used_for: String,
hint: String,
},
DuplicateTypeName {
name: String,
hint: String,
},
OperationTypeCollision {
name: String,
first: String,
second: String,
hint: String,
},
RecursiveAlias {
cycle: Vec<String>,
hint: String,
},
SchemaNameCollision {
ident: String,
first: String,
second: String,
hint: String,
},
OperationNameCollision {
ident: String,
first: String,
second: String,
hint: String,
},
InvalidTypeNameSuffix {
suffix: String,
hint: String,
},
InvalidGeneratedCode {
source: Error,
},
Validation {
problems: Vec<Error>,
},
}Expand description
Errors that can occur while loading a spec or generating code.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ReadSpec
The spec file cannot be read from disk.
ParseSpec
The spec file cannot be parsed as OpenAPI YAML/JSON.
ReadRefFile
A referenced external file cannot be read from disk.
ParseRefFile
A referenced external file cannot be parsed as OpenAPI YAML/JSON.
Fields
ReadConfig
The configuration file cannot be read from disk.
ParseConfig
The configuration file cannot be parsed as YAML.
Unimplemented(String)
The requested generation mode is not implemented yet.
WriteOutput
Writing the generated output failed.
ReadOutput
Reading the output file for a comparison failed.
An absent file is not this error. --check reports an absent file as
drift, because generation creates it. This covers a file that exists and
that the process cannot read, such as a directory or a file with no read
permission.
UnsupportedSpecVersion
The document declares an OpenAPI version the generator does not read.
Only 3.0.x is supported. A newer document is rejected and not read as a
3.0 document, because the dialects overlap: one whose every construct
happens to parse as 3.0 would generate quietly, and one newer construct in
the same file would fail with a serde message that names no version.
Fields
UnsupportedSpecKey
The document declares a top-level key the generator cannot generate from.
webhooks: is the case. It is a 3.1 key that carries operations, and a
generator that ignores it emits no handler for any of them. Silence here
reads as “the spec declares no such operation”.
Fields
UnresolvedRef(String)
A $ref pointed at something that cannot be resolved.
UnsupportedRef
A $ref used a form the generator does not support yet.
InvalidExtensionValue
An x- extension carried a value of a kind the generator cannot read.
The author wrote the key to change something. A silent fallback to the default would hide that nothing changed.
Fields
UnsupportedSchema
A schema combined keywords in a way the generator cannot represent.
SchemaDepthExceeded
Inline schema nesting exceeded the depth the generator will lower, guarding against stack exhaustion on hostile or pathological specs.
Fields
UnsupportedOperation
An operation used a feature the server generator does not support yet.
Fields
UnsupportedContentType
A request or response body declares content, and no content type the generator can represent.
This is not a bodyless body. A bodyless response declares no content:
at all, and 204 is the common case. A body that declares
application/pdf states that a payload exists, so emitting no field for
it drops the payload with no message.
Both directions report through this one variant, because both make the same statement about the same input. The remedy differs by direction, so the hint carries it.
Fields
UnsupportedDefault
The schema default does not fit the Rust type of the field. Either the
two disagree, or the value has no literal form here. A dropped default
leaves the document and the code in disagreement.
Fields
InvalidPathParameter
A parameter declared in: path has no matching {placeholder} in the
operation’s path template. An OpenAPI path parameter must appear in the
path, and lowering it from the template will otherwise silently drop it
from the generated signature.
Fields
UndeclaredPathParameter
A {placeholder} in the operation’s path template has no matching
parameter declared in: path. The generator cannot know the parameter’s
type, so rather than silently assume String it requires the parameter
to be declared (matching the OpenAPI requirement that every path template
variable have a corresponding path parameter).
Fields
TypeNameCollision
A generated per-operation type name collided with a component-model name emitted in the same file.
Fields
PreludeShadowing
A generated type took the name of a Rust prelude type that the emitted
code writes unqualified, such as Option or Vec.
The name does not duplicate an emitted item, so no other collision check sees it. It shadows the prelude inside the generated file instead, and every use of the shadowed type there stops compiling.
Fields
DuplicateTypeName
Two emitted items took one Rust type name, and at least one of them came from an inline schema that lowering hoisted to the crate root.
Two component schemas that collapse onto one identifier are reported as
Error::SchemaNameCollision, which names both schemas. A hoisted inline
schema has no name of its own, so this variant names the identifier only.
Fields
OperationTypeCollision
A per-operation type took the Rust type name of a second per-operation type, or of a generator interface.
Every per-operation type name derives from the method name of its
operation and a fixed suffix, so two of them clash when a configured suffix
makes them equal, or when two method names differ only by a suffix that
another artifact also adds. The same suffix can also give a per-operation
type the fixed name of a requested interface, such as the Api trait.
A clash with a model is reported as Error::TypeNameCollision instead,
because the remedy names the schema and not an operation.
Fields
RecursiveAlias
Two or more type aliases refer to each other in a cycle.
type A = B; type B = A; is a cycle rustc rejects with E0391, and no
amount of indirection fixes it: a Box around either side still expands
forever. The recursion pass boxes a struct field or a union variant, and
a cycle made only of aliases offers neither.
Fields
SchemaNameCollision
Two component schema names collapsed onto one Rust identifier.
The generator will not choose which schema keeps the plain name, because that choice belongs to the spec author.
Fields
OperationNameCollision
Two operations collapsed onto one Rust method name.
Every artifact of an operation derives from this one name, so the file holds a duplicate trait method, response enum, and handler, and the router points both routes at one handler. The generator will not choose which operation keeps the plain name, because that choice belongs to the spec author.
Fields
InvalidTypeNameSuffix
output-options.type-name-suffix holds no identifier characters.
Casing drops punctuation and separators, so a suffix such as - or _
adds nothing to a type name. The generator cannot resolve a collision with
such a suffix, because the second name stays the same as the first.
Fields
InvalidGeneratedCode
The generated token stream was not valid Rust (internal bug).
Validation
One pass found several independent semantic problems.
This variant holds two or more problems. One problem returns as itself, so
a caller can match that variant. See
crate::lower::validate::Diagnostics::into_result. This variant never
nests, because the collector holds leaf errors only.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()