Commit 9d4a2ff
authored
Improve error message when encountering unexpected content-type headers (#104)
### Motivation
When the server response has a content-type header that does not conform
to the OpenAPI document, we currently throw an error. However, this
error presents itself in a very confusing manner: it prints `Unexpected
Content-Type header: application/json`, where `application/json is the
_expected_ content-type. At best, this is ambiguous and potentially
misleading.
### Modifications
- Extend `case RuntimeError.unexpectedContentTypeHeader` with _both_ the
expected and received content-type associated values.
- Update the printed description to include both the expected and
received content-type header values.
### Result
When an unexpected content-type is received, the error message is
clearer.
### Test Plan
Updated the existing test that expects an error to check the error and
that the error values are provided in the correct order.1 parent 6e2f9b9 commit 9d4a2ff
File tree
3 files changed
+20
-5
lines changed- Sources/OpenAPIRuntime
- Conversion
- Errors
- Tests/OpenAPIRuntimeTests/Conversion
3 files changed
+20
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
65 | 70 | | |
66 | 71 | | |
67 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
88 | 97 | | |
89 | 98 | | |
90 | 99 | | |
| |||
0 commit comments