satay_codegen/error/validation.rs
1/// Errors that can occur while validating an OpenAPI document.
2///
3/// This enum is [`non_exhaustive`](https://doc.rust-lang.org/reference/attributes/type_system.html)
4/// so new variants may be added in future releases without a semver break.
5#[derive(Debug, thiserror::Error)]
6#[non_exhaustive]
7pub enum ValidationError {
8 // -- Document and component shape validation --
9 /// The OpenAPI version is not supported.
10 ///
11 /// Error message: `unsupported OpenAPI version `{version}`; Satay supports OpenAPI 3.1`
12 #[error("unsupported OpenAPI version `{version}`; Satay supports OpenAPI 3.1")]
13 UnsupportedOpenApiVersion { version: String },
14
15 /// A schema component uses a type that is not supported.
16 ///
17 /// Error message: `unsupported type `{kind}` in schema `{schema}``
18 #[error("unsupported type `{kind}` in schema `{schema}`")]
19 UnsupportedComponentType { schema: String, kind: String },
20
21 /// A schema component is missing a required `type`, `$ref`, `enum`, or `properties` declaration.
22 ///
23 /// Error message: `schema `{schema}` must declare `type`, `$ref`, `enum`, or `properties``
24 #[error("schema `{schema}` must declare `type`, `$ref`, `enum`, or `properties`")]
25 MissingComponentSchemaType { schema: String },
26
27 /// An object schema is missing the required `properties` field.
28 ///
29 /// Error message: `object schema `{schema}` must declare `properties``
30 #[error("object schema `{schema}` must declare `properties`")]
31 MissingObjectProperties { schema: String },
32
33 /// The OpenAPI document is missing the required `paths` field.
34 ///
35 /// Error message: `OpenAPI document must declare `paths``
36 #[error("OpenAPI document must declare `paths`")]
37 MissingPaths,
38
39 // -- Enum and schema type validation --
40 /// A schema uses an enum with a non-string type.
41 ///
42 /// Error message: `{context} uses enum type `{kind}`; only string enums are supported`
43 #[error("{context} uses enum type `{kind}`; only string enums are supported")]
44 UnsupportedEnumType { context: String, kind: String },
45
46 /// A schema declares an enum that is not an array.
47 ///
48 /// Error message: `{context} has a non-array enum`
49 #[error("{context} has a non-array enum")]
50 NonArrayEnum { context: String },
51
52 /// A schema declares an enum with no values.
53 ///
54 /// Error message: `{context} has an empty enum`
55 #[error("{context} has an empty enum")]
56 EmptyEnum { context: String },
57
58 /// A schema enum contains a non-string value.
59 ///
60 /// Error message: `{context} contains a non-string enum value; only string enums are supported`
61 #[error("{context} contains a non-string enum value; only string enums are supported")]
62 NonStringEnumValue { context: String },
63
64 /// A schema declares a `const` value that is not one of its `enum` values.
65 ///
66 /// Error message: `{context} declares a `const` value that is not in its `enum``
67 #[error("{context} declares a `const` value that is not in its `enum`")]
68 ConstNotInEnum { context: String },
69
70 /// An `x-satay.enum-variants` value is not an object.
71 ///
72 /// Error message: `{context}.x-satay.enum-variants must be an object`
73 #[error("{context}.x-satay.enum-variants must be an object")]
74 InvalidSatayEnumVariants { context: String },
75
76 /// An `x-satay.enum-variants` entry points at a value that is not in the enum.
77 ///
78 /// Error message: `{context}.x-satay.enum-variants contains `{wire_name}`, which is not declared in the enum`
79 #[error(
80 "{context}.x-satay.enum-variants contains `{wire_name}`, which is not declared in the enum"
81 )]
82 UnknownSatayEnumVariantValue { context: String, wire_name: String },
83
84 /// An `x-satay.enum-variants` entry has a non-string Rust variant name.
85 ///
86 /// Error message: `{context}.x-satay.enum-variants[{wire_name:?}] must be a string`
87 #[error("{context}.x-satay.enum-variants[{wire_name:?}] must be a string")]
88 InvalidSatayEnumVariantName { context: String, wire_name: String },
89
90 /// An `x-satay.enum-variants` entry uses a name reserved for generated fallback variants.
91 ///
92 /// Error message: `{context}.x-satay.enum-variants[{wire_name:?}] uses reserved fallback variant `{rust_name}``
93 #[error(
94 "{context}.x-satay.enum-variants[{wire_name:?}] uses reserved fallback variant `{rust_name}`"
95 )]
96 ReservedSatayEnumVariantName {
97 context: String,
98 wire_name: String,
99 rust_name: String,
100 },
101
102 /// Two `x-satay.enum-variants` entries produce the same Rust variant name.
103 ///
104 /// Error message: `{context}.x-satay.enum-variants maps multiple values to `{rust_name}``
105 #[error("{context}.x-satay.enum-variants maps multiple values to `{rust_name}`")]
106 DuplicateSatayEnumVariantName { context: String, rust_name: String },
107
108 /// A schema has a `required` field that is not an array.
109 ///
110 /// Error message: `{context} has a non-array `required` field`
111 #[error("{context} has a non-array `required` field")]
112 NonArrayRequired { context: String },
113
114 /// A schema `required` array contains a non-string element.
115 ///
116 /// Error message: `{context} has a non-string required field name`
117 #[error("{context} has a non-string required field name")]
118 NonStringRequiredField { context: String },
119
120 /// An integer schema uses an unsupported format.
121 ///
122 /// Error message: `{context} uses unsupported integer format `{format}``
123 #[error("{context} uses unsupported integer format `{format}`")]
124 UnsupportedIntegerFormat { context: String, format: String },
125
126 /// A number schema uses an unsupported format.
127 ///
128 /// Error message: `{context} uses unsupported number format `{format}``
129 #[error("{context} uses unsupported number format `{format}`")]
130 UnsupportedNumberFormat { context: String, format: String },
131
132 /// An `x-satay.parse-as` value is not a supported target type.
133 ///
134 /// Error message: `{context} uses unsupported x-satay.parse-as `{parse_as}``
135 #[error("{context} uses unsupported x-satay.parse-as `{parse_as}`")]
136 UnsupportedSatayParseAs { context: String, parse_as: String },
137
138 /// An `x-satay.parse-as` value is not a string.
139 ///
140 /// Error message: `{context}.x-satay.parse-as must be a string`
141 #[error("{context}.x-satay.parse-as must be a string")]
142 InvalidSatayParseAs { context: String },
143
144 /// `x-satay.parse-as` was applied to an unsupported wire schema.
145 ///
146 /// Error message: `{context} uses x-satay.parse-as `{parse_as}` on `{kind}`; supported parse-as wire schemas are string schemas, plus integer schemas for bool`
147 #[error(
148 "{context} uses x-satay.parse-as `{parse_as}` on `{kind}`; supported parse-as wire schemas are string schemas, plus integer schemas for bool"
149 )]
150 SatayParseAsRequiresString {
151 context: String,
152 parse_as: String,
153 kind: String,
154 },
155
156 /// An `x-satay.integer-type` value is not a supported Rust integer type.
157 ///
158 /// Error message: `{context} uses unsupported x-satay.integer-type `{integer_type}``
159 #[error("{context} uses unsupported x-satay.integer-type `{integer_type}`")]
160 UnsupportedSatayIntegerType {
161 context: String,
162 integer_type: String,
163 },
164
165 /// An `x-satay.integer-type` value is not a string.
166 ///
167 /// Error message: `{context}.x-satay.integer-type must be a string`
168 #[error("{context}.x-satay.integer-type must be a string")]
169 InvalidSatayIntegerType { context: String },
170
171 /// `x-satay.integer-type` was applied to a non-integer schema.
172 ///
173 /// Error message: `{context} uses x-satay.integer-type `{integer_type}` on `{kind}`; supported integer-type wire schemas are integer schemas and string schemas with x-satay.parse-as integer-range`
174 #[error(
175 "{context} uses x-satay.integer-type `{integer_type}` on `{kind}`; supported integer-type wire schemas are integer schemas and string schemas with x-satay.parse-as integer-range"
176 )]
177 SatayIntegerTypeRequiresInteger {
178 context: String,
179 integer_type: String,
180 kind: String,
181 },
182
183 /// An array schema is missing the required `items` field.
184 ///
185 /// Error message: `{context} array schema must declare `items``
186 #[error("{context} array schema must declare `items`")]
187 MissingArrayItems { context: String },
188
189 /// A schema defines an inline object instead of using a `$ref`.
190 ///
191 /// Error message: `{context} is an inline object schema; move it to components/schemas and use `$ref``
192 #[error("{context} is an inline object schema; move it to components/schemas and use `$ref`")]
193 InlineObjectSchema { context: String },
194
195 /// An object schema has no properties (i.e. acts as a map/dictionary), which is unsupported.
196 ///
197 /// Error message: `{context} is an object without properties; map/object schemas are not supported yet`
198 #[error("{context} is an object without properties; map/object schemas are not supported yet")]
199 UnsupportedMapObjectSchema { context: String },
200
201 /// A schema uses an unsupported type.
202 ///
203 /// Error message: `{context} uses unsupported schema type `{kind}``
204 #[error("{context} uses unsupported schema type `{kind}`")]
205 UnsupportedSchemaType { context: String, kind: String },
206
207 /// A schema is missing a required `type`, `$ref`, or `enum` declaration.
208 ///
209 /// Error message: `{context} must declare `type`, `$ref`, or `enum``
210 #[error("{context} must declare `type`, `$ref`, or `enum`")]
211 MissingSchemaType { context: String },
212
213 /// A JSON Schema boolean schema was used; Satay has no IR equivalent yet.
214 ///
215 /// Error message: `{context} is a boolean schema; boolean JSON Schemas are not supported yet`
216 #[error("{context} is a boolean schema; boolean JSON Schemas are not supported yet")]
217 UnsupportedBooleanSchema { context: String },
218
219 /// A schema type array contains more than one non-null type.
220 ///
221 /// Error message: `{context} declares multiple non-null schema types; Satay supports at most one plus null`
222 #[error(
223 "{context} declares multiple non-null schema types; Satay supports at most one plus null"
224 )]
225 MultipleNonNullSchemaTypesUnsupported { context: String },
226
227 /// A schema uses a composition keyword (`allOf`, `anyOf`, `oneOf`) in an unsupported context.
228 ///
229 /// Error message: `{context} uses `{keyword}`, which is not supported in this context`
230 #[error("{context} uses `{keyword}`, which is not supported in this context")]
231 UnsupportedComposition {
232 context: String,
233 keyword: &'static str,
234 },
235
236 /// An `allOf` schema combines supported struct flattening with another schema keyword.
237 ///
238 /// Error message: `{context} uses `allOf` with `{keyword}`; only object branch flattening is supported`
239 #[error("{context} uses `allOf` with `{keyword}`; only object branch flattening is supported")]
240 UnsupportedAllOfSiblingKeyword { context: String, keyword: String },
241
242 /// An `allOf` branch cannot be flattened into a generated Rust struct.
243 ///
244 /// Error message: `{context}.allOf[{index}] must be a local component schema reference or object schema with properties`
245 #[error(
246 "{context}.allOf[{index}] must be a local component schema reference or object schema with properties"
247 )]
248 UnsupportedAllOfBranch { context: String, index: usize },
249
250 /// Two `allOf` branches declare the same object property.
251 ///
252 /// Error message: `{context} declares duplicate `allOf` property `{property}``
253 #[error("{context} declares duplicate `allOf` property `{property}`")]
254 DuplicateAllOfProperty { context: String, property: String },
255
256 /// `allOf` component schemas form a recursive flattening cycle.
257 ///
258 /// Error message: `{context} forms a recursive `allOf` cycle through schema `{schema}``
259 #[error("{context} forms a recursive `allOf` cycle through schema `{schema}`")]
260 RecursiveAllOf { context: String, schema: String },
261
262 /// A discriminator union branch component recursively contains its own union.
263 ///
264 /// Error message: `{context} forms a recursive discriminator cycle through branch schema `{schema}``
265 #[error("{context} forms a recursive discriminator cycle through branch schema `{schema}`")]
266 RecursiveDiscriminatorBranch { context: String, schema: String },
267
268 /// An `anyOf` schema combines a supported union with another schema keyword.
269 ///
270 /// Error message: `{context} uses `anyOf` with `{keyword}`; only annotation siblings are supported`
271 #[error("{context} uses `anyOf` with `{keyword}`; only annotation siblings are supported")]
272 UnsupportedAnyOfSiblingKeyword { context: String, keyword: String },
273
274 /// An `anyOf` branch is not a supported union branch.
275 ///
276 /// Error message: `{context}.anyOf[{index}] must be a local component schema reference, inline string enum, inline primitive schema, or null schema`
277 #[error(
278 "{context}.anyOf[{index}] must be a local component schema reference, inline string enum, inline primitive schema, or null schema"
279 )]
280 UnsupportedAnyOfBranch { context: String, index: usize },
281
282 /// A `oneOf` schema combines a supported union with another schema keyword.
283 ///
284 /// Error message: `{context} uses `oneOf` with `{keyword}`; only annotation siblings are supported`
285 #[error("{context} uses `oneOf` with `{keyword}`; only annotation siblings are supported")]
286 UnsupportedOneOfSiblingKeyword { context: String, keyword: String },
287
288 /// A `oneOf` branch is not a supported union branch.
289 ///
290 /// Error message: `{context}.oneOf[{index}] must be a local component schema reference, inline string enum, inline primitive schema, or null schema`
291 #[error(
292 "{context}.oneOf[{index}] must be a local component schema reference, inline string enum, inline primitive schema, or null schema"
293 )]
294 UnsupportedOneOfBranch { context: String, index: usize },
295
296 /// A plain `anyOf` or `oneOf` union has more than one null branch.
297 ///
298 /// Error message: `{context}.{keyword}[{index}] duplicates the union null branch`
299 #[error("{context}.{keyword}[{index}] duplicates the union null branch")]
300 DuplicateUnionNullBranch {
301 context: String,
302 keyword: &'static str,
303 index: usize,
304 },
305
306 /// A nullable plain `anyOf` or `oneOf` union has no non-null branches.
307 ///
308 /// Error message: `{context}.{keyword} must declare at least one non-null branch`
309 #[error("{context}.{keyword} must declare at least one non-null branch")]
310 NullableUnionWithoutVariants {
311 context: String,
312 keyword: &'static str,
313 },
314
315 /// A plain `anyOf` or `oneOf` union has a branch that is statically shadowed by an earlier branch.
316 ///
317 /// Error message: `{context}.{keyword}[{index}] is shadowed by earlier branch {shadowed_by} under ordered serde untagged deserialization`
318 #[error(
319 "{context}.{keyword}[{index}] is shadowed by earlier branch {shadowed_by} under ordered serde untagged deserialization"
320 )]
321 ShadowedUnionBranch {
322 context: String,
323 keyword: &'static str,
324 index: usize,
325 shadowed_by: usize,
326 },
327
328 /// A composition schema declares no branches.
329 ///
330 /// Raised for empty `anyOf` and, today, for empty component `allOf` that is routed
331 /// through the shared empty composition-shape check.
332 ///
333 /// Error message: `{context} must declare at least one `anyOf` branch`
334 #[error("{context} must declare at least one `anyOf` branch")]
335 EmptyAnyOf { context: String },
336
337 /// `anyOf` component schemas form a recursive union cycle.
338 ///
339 /// Error message: `{context} forms a recursive `anyOf` cycle through schema `{schema}``
340 #[error("{context} forms a recursive `anyOf` cycle through schema `{schema}`")]
341 RecursiveAnyOf { context: String, schema: String },
342
343 /// A discriminator union does not use exactly one non-empty `anyOf` or `oneOf` branch list.
344 ///
345 /// Error message: `{context} discriminator unions must declare exactly one non-empty `anyOf` or `oneOf` branch list`
346 #[error(
347 "{context} discriminator unions must declare exactly one non-empty `anyOf` or `oneOf` branch list"
348 )]
349 InvalidDiscriminatorUnion { context: String },
350
351 /// A discriminator union branch is not a local component schema reference.
352 ///
353 /// Error message: `{context}.{keyword}[{index}] must be a local component schema reference when using `discriminator``
354 #[error(
355 "{context}.{keyword}[{index}] must be a local component schema reference when using `discriminator`"
356 )]
357 UnsupportedDiscriminatorBranch {
358 context: String,
359 keyword: &'static str,
360 index: usize,
361 },
362
363 /// A discriminator union branch target does not generate as an object struct.
364 ///
365 /// Error message: `{context} discriminator branch `{schema}` must be an object struct component`
366 #[error("{context} discriminator branch `{schema}` must be an object struct component")]
367 DiscriminatorBranchNotObject { context: String, schema: String },
368
369 /// A discriminator branch object contains the discriminator property.
370 ///
371 /// Error message: `{context} discriminator branch `{schema}` contains discriminator property `{property}``
372 #[error(
373 "{context} discriminator branch `{schema}` contains discriminator property `{property}`"
374 )]
375 DiscriminatorPropertyConflict {
376 context: String,
377 schema: String,
378 property: String,
379 },
380
381 /// A discriminator branch object contains an invalid embedded discriminator property.
382 ///
383 /// Error message: `{context} discriminator branch `{schema}` property `{property}` must be {expected}`
384 #[error("{context} discriminator branch `{schema}` property `{property}` must be {expected}")]
385 InvalidDiscriminatorProperty {
386 context: String,
387 schema: String,
388 property: String,
389 expected: &'static str,
390 },
391
392 /// A discriminator mapping entry targets a non-local schema or a schema outside the union branches.
393 ///
394 /// Error message: `{context}.discriminator.mapping[{value:?}] targets `{target}`, which is not a local union branch schema`
395 #[error(
396 "{context}.discriminator.mapping[{value:?}] targets `{target}`, which is not a local union branch schema"
397 )]
398 InvalidDiscriminatorMapping {
399 context: String,
400 value: String,
401 target: String,
402 },
403
404 /// Multiple discriminator mapping values target the same union branch schema.
405 ///
406 /// Error message: `{context}.discriminator.mapping maps multiple values to branch schema `{schema}``
407 #[error("{context}.discriminator.mapping maps multiple values to branch schema `{schema}`")]
408 DuplicateDiscriminatorMapping { context: String, schema: String },
409
410 /// A discriminator mapping value disagrees with a branch's embedded discriminator property value.
411 ///
412 /// Error message: `{context}.discriminator.mapping maps value `{value}` to branch schema `{schema}`, but the branch declares discriminator value `{actual}`
413 #[error(
414 "{context}.discriminator.mapping maps value `{value}` to branch schema `{schema}`, but the branch declares discriminator value `{actual}`"
415 )]
416 DiscriminatorMappingValueMismatch {
417 context: String,
418 schema: String,
419 value: String,
420 actual: String,
421 },
422
423 /// Multiple discriminator branches resolve to the same discriminator value after implicit defaults are applied.
424 ///
425 /// Error message: `{context}.discriminator resolves multiple branch schemas to value `{value}``
426 #[error("{context}.discriminator resolves multiple branch schemas to value `{value}`")]
427 DuplicateDiscriminatorValue { context: String, value: String },
428
429 // -- Schema constraint validation --
430 /// A string schema specifies a `minLength` greater than its `maxLength`.
431 ///
432 /// Error message: `{context} has minLength {min_length} greater than maxLength {max_length}`
433 #[error("{context} has minLength {min_length} greater than maxLength {max_length}")]
434 InvalidStringLengthBounds {
435 context: String,
436 min_length: u64,
437 max_length: u64,
438 },
439
440 /// A schema uses `uniqueItems`, which cannot be enforced by generated `Vec`-backed types.
441 ///
442 /// Error message: `{context} uses `uniqueItems`; generated Vec-backed types cannot enforce uniqueness yet`
443 #[error(
444 "{context} uses `uniqueItems`; generated Vec-backed types cannot enforce uniqueness yet"
445 )]
446 UniqueItemsUnsupported { context: String },
447
448 /// An array schema specifies `minItems` greater than `maxItems`.
449 ///
450 /// Error message: `{context} has minItems {min_items} greater than maxItems {max_items}`
451 #[error("{context} has minItems {min_items} greater than maxItems {max_items}")]
452 InvalidArrayLengthBounds {
453 context: String,
454 min_items: u64,
455 max_items: u64,
456 },
457
458 /// A schema uses a keyword that is not safely supported.
459 ///
460 /// Error message: `{context} uses `{keyword}`, which is not safely supported yet`
461 #[error("{context} uses `{keyword}`, which is not safely supported yet")]
462 UnsupportedKeyword {
463 context: String,
464 keyword: &'static str,
465 },
466
467 /// A schema keyword that must be a non-negative integer has an invalid value.
468 ///
469 /// Error message: `{context}.{keyword} must be a non-negative integer`
470 #[error("{context}.{keyword} must be a non-negative integer")]
471 InvalidNonNegativeIntegerKeyword {
472 context: String,
473 keyword: &'static str,
474 },
475
476 /// A schema keyword that must be a boolean has an invalid value.
477 ///
478 /// Error message: `{context}.{keyword} must be a boolean`
479 #[error("{context}.{keyword} must be a boolean")]
480 InvalidBooleanKeyword {
481 context: String,
482 keyword: &'static str,
483 },
484
485 /// An `exclusiveMinimum`/`exclusiveMaximum` keyword is present but the corresponding bound is missing.
486 ///
487 /// Error message: `{context}.{exclusive_keyword} requires `{keyword}``
488 #[error("{context}.{exclusive_keyword} requires `{keyword}`")]
489 ExclusiveLimitRequiresBound {
490 context: String,
491 exclusive_keyword: &'static str,
492 keyword: &'static str,
493 },
494
495 /// A schema keyword that must be a finite number has a non-finite value.
496 ///
497 /// Error message: `{context}.{keyword} must be a finite number`
498 #[error("{context}.{keyword} must be a finite number")]
499 InvalidFiniteNumberKeyword {
500 context: String,
501 keyword: &'static str,
502 },
503
504 /// A value expected to be an integer is not.
505 ///
506 /// Error message: `{context} must be an integer`
507 #[error("{context} must be an integer")]
508 ExpectedInteger { context: String },
509
510 /// Integer bounds (minimum/maximum) do not permit any value.
511 ///
512 /// Error message: `{context} integer bounds do not allow any value`
513 #[error("{context} integer bounds do not allow any value")]
514 EmptyIntegerBounds { context: String },
515
516 /// An exclusive integer minimum overflows `i64`.
517 ///
518 /// Error message: `exclusive integer minimum overflows`
519 #[error("exclusive integer minimum overflows")]
520 ExclusiveIntegerMinimumOverflow,
521
522 /// An exclusive integer maximum overflows `i64`.
523 ///
524 /// Error message: `exclusive integer maximum overflows`
525 #[error("exclusive integer maximum overflows")]
526 ExclusiveIntegerMaximumOverflow,
527
528 /// Number bounds (minimum/maximum) do not permit any value.
529 ///
530 /// Error message: `{context} number bounds do not allow any value`
531 #[error("{context} number bounds do not allow any value")]
532 EmptyNumberBounds { context: String },
533
534 // -- Operation, parameter, and response validation --
535 /// An operation does not declare any responses.
536 ///
537 /// Error message: `operation `{operation_id}` must declare responses`
538 #[error("operation `{operation_id}` must declare responses")]
539 MissingOperationResponses { operation_id: String },
540
541 /// A value expected to be an array is not.
542 ///
543 /// Error message: `{context} must be an array`
544 #[error("{context} must be an array")]
545 ExpectedArray { context: String },
546
547 /// A parameter uses an unsupported location (e.g. cookie) instead of path, query, or header.
548 ///
549 /// Error message: `{context} parameter `{wire_name}` is in `{location}`; only path, query, and header parameters are supported`
550 #[error(
551 "{context} parameter `{wire_name}` is in `{location}`; only path, query, and header parameters are supported"
552 )]
553 UnsupportedParameterLocation {
554 context: String,
555 wire_name: String,
556 location: String,
557 },
558
559 /// A parameter uses `content` instead of `schema`.
560 ///
561 /// Error message: `{context} parameter `{wire_name}` uses `content`; schema parameters are required`
562 #[error("{context} parameter `{wire_name}` uses `content`; schema parameters are required")]
563 ContentParameterUnsupported { context: String, wire_name: String },
564
565 /// A parameter is missing a required `schema` declaration.
566 ///
567 /// Error message: `{context} parameter `{wire_name}` must declare schema`
568 #[error("{context} parameter `{wire_name}` must declare schema")]
569 MissingParameterSchema { context: String, wire_name: String },
570
571 /// A parameter is nullable, which is not supported.
572 ///
573 /// Error message: `parameter `{wire_name}` is nullable; nullable parameters are not supported`
574 #[error("parameter `{wire_name}` is nullable; nullable parameters are not supported")]
575 NullableParameterUnsupported { wire_name: String },
576
577 /// A parameter uses `anyOf`, which is not supported for URI/header encoding yet.
578 ///
579 /// Error message: `parameter `{wire_name}` uses `anyOf`; anyOf parameters are not supported yet`
580 #[error("parameter `{wire_name}` uses `anyOf`; anyOf parameters are not supported yet")]
581 AnyOfParameterUnsupported { wire_name: String },
582
583 /// A path parameter is an array, which is not supported.
584 ///
585 /// Error message: `path parameter `{wire_name}` is an array; array path parameter styles are not supported`
586 #[error(
587 "path parameter `{wire_name}` is an array; array path parameter styles are not supported"
588 )]
589 ArrayPathParameterUnsupported { wire_name: String },
590
591 /// A header parameter is an array, which is not supported.
592 ///
593 /// Error message: `header parameter `{wire_name}` is an array; array header parameter styles are not supported`
594 #[error(
595 "header parameter `{wire_name}` is an array; array header parameter styles are not supported"
596 )]
597 ArrayHeaderParameterUnsupported { wire_name: String },
598
599 /// A path parameter does not set `required: true`.
600 ///
601 /// Error message: `path parameter `{wire_name}` must set required: true`
602 #[error("path parameter `{wire_name}` must set required: true")]
603 PathParameterNotRequired { wire_name: String },
604
605 /// A context is missing a required `content` declaration.
606 ///
607 /// Error message: `{context} must declare content`
608 #[error("{context} must declare content")]
609 MissingContent { context: String },
610
611 /// A context is missing the required `application/json` content type.
612 ///
613 /// Error message: `{context} must declare application/json content`
614 #[error("{context} must declare application/json content")]
615 MissingJsonContent { context: String },
616
617 /// A context's `application/json` content is missing a schema.
618 ///
619 /// Error message: `{context} application/json content must declare schema`
620 #[error("{context} application/json content must declare schema")]
621 MissingJsonSchema { context: String },
622
623 /// A response body uses the `default` status, which is not yet supported for decoding.
624 ///
625 /// Error message: `{context} contains a default response body; default response decoding is not supported yet`
626 #[error(
627 "{context} contains a default response body; default response decoding is not supported yet"
628 )]
629 DefaultResponseBodyUnsupported { context: String },
630
631 /// A response contains an invalid HTTP status code string.
632 ///
633 /// Error message: `{context} contains invalid status code `{status}``
634 #[error("{context} contains invalid status code `{status}`")]
635 InvalidStatusCode { context: String, status: String },
636
637 /// A response contains a status code outside the valid 100–599 range.
638 ///
639 /// Error message: `{context} contains out-of-range status code `{status_code}``
640 #[error("{context} contains out-of-range status code `{status_code}`")]
641 OutOfRangeStatusCode { context: String, status_code: u16 },
642
643 /// A response for a given status code is missing `application/json` content.
644 ///
645 /// Error message: `{context} {status} response must declare application/json content`
646 #[error("{context} {status} response must declare application/json content")]
647 MissingResponseJsonContent { context: String, status: String },
648
649 /// A path template contains a parameter that is never closed.
650 ///
651 /// Error message: `path `{path}` contains an unclosed parameter`
652 #[error("path `{path}` contains an unclosed parameter")]
653 UnclosedPathParameter { path: String },
654
655 /// A path template contains an empty parameter (e.g. `{}`).
656 ///
657 /// Error message: `path `{path}` contains an empty parameter`
658 #[error("path `{path}` contains an empty parameter")]
659 EmptyPathParameter { path: String },
660
661 /// A path template references a parameter that is not declared in the operation's parameters.
662 ///
663 /// Error message: `path `{path}` uses parameter `{name}` but it is not declared`
664 #[error("path `{path}` uses parameter `{name}` but it is not declared")]
665 UndeclaredPathParameter { path: String, name: String },
666
667 /// A parameter is declared for a path but never used in the path template.
668 ///
669 /// Error message: `path parameter `{name}` is declared but not used in path `{path}``
670 #[error("path parameter `{name}` is declared but not used in path `{path}`")]
671 UnusedPathParameter { path: String, name: String },
672
673 // -- Reference resolution and JSON shape validation --
674 /// A `$ref` could not be resolved because the referenced component failed validation.
675 ///
676 /// Error message: `failed to resolve reference `{reference}` in {context}: {source}`
677 #[error("failed to resolve reference `{reference}` in {context}: {source}")]
678 ResolveReference {
679 reference: String,
680 context: String,
681 #[source]
682 source: Box<ValidationError>,
683 },
684
685 /// A reference points to an external document; only local (`#`) references are supported.
686 ///
687 /// Error message: `only local references are supported`
688 #[error("only local references are supported")]
689 NonLocalReference,
690
691 /// A local reference is not a valid JSON pointer.
692 ///
693 /// Error message: `local reference must be a JSON pointer`
694 #[error("local reference must be a JSON pointer")]
695 InvalidLocalReference,
696
697 /// A JSON pointer is missing a required token segment.
698 ///
699 /// Error message: `missing `{token}``
700 #[error("missing `{token}`")]
701 MissingJsonPointerToken { token: String },
702
703 /// A `$ref` does not point to the expected `#/components/{section}/…` path.
704 ///
705 /// Error message: `reference `{reference}` must point to #/components/{section}/...`
706 #[error("reference `{reference}` must point to #/components/{section}/...")]
707 InvalidComponentReference {
708 reference: String,
709 section: &'static str,
710 },
711
712 /// A local `$ref` chain references itself.
713 ///
714 /// Error message: `circular reference `{reference}``
715 #[error("circular reference `{reference}`")]
716 CircularReference { reference: String },
717
718 /// A value expected to be an object is not.
719 ///
720 /// Error message: `{context} must be an object`
721 #[error("{context} must be an object")]
722 ExpectedObject { context: String },
723
724 /// A nested field expected to be an object is not.
725 ///
726 /// Error message: `{context}.{field} must be an object`
727 #[error("{context}.{field} must be an object")]
728 ExpectedObjectField {
729 context: String,
730 field: &'static str,
731 },
732}