Commit 0030548
Add SPIs for throwing RuntimeError from shorthand generated APIs (#56)
### Motivation
The review period for SOAR-0007 (Shorthand APIs for inputs and outputs)
has now concluded. This pull request adds the required SPIs to the
runtime library to throw a runtime error when the response and/or body
does not match that of the shorthand API being used.
For further context, please review the proposal itself.[^1]
[^1]: apple/swift-openapi-generator#291
### Modifications
- Extend `internal enum RuntimeError: Error` with two new cases:
- `.unexpectedResponseStatus(expectedStatus:response:)`
- `.unexpectedResponseBody(expectedContent:body:)`
- Add SPI for generated code, to throw these errors:
- `@_spi(Generated) public
throwUnexpectedResponseStatus(expectedStatus:response:)`
- `@_spi(Generated) public
throwUnexpectedResponseBody(expectedStatus:body:)`
### Result
Runtime library has two SPIs that can be used by the generator to
implement the shorthand throwing getter APIs described in SOAR-0007.
### Test Plan
Companion PR in swift-openapi-generator.
---------
Signed-off-by: Si Beaumont <beaumont@apple.com>
Co-authored-by: Honza Dvorsky <honza@apple.com>1 parent 1eaf236 commit 0030548
1 file changed
+18
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
| |||
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
0 commit comments