Open
Description
Motivation
Currently, a computed var json
is generated for every REST response body. Unfortunately, this var is marked as throws
even if application/json
is the only content type defined for that response body. This is the case for 100% of our REST API methods, and I imagine is the most common case across all users of this library.
/// The associated value of the enum case if `self` is `.json`.
///
/// - Throws: An error if `self` is not `.json`.
/// - SeeAlso: `.json`.
public var json: Operations.postLinkedAccounts.Output.Conflict.Body.jsonPayload {
get throws {
switch self {
case let .json(body):
return body
}
}
}
This means that at the call site, I have to use try!
to do something that is in reality perfectly safe:
case .conflict(let error): throw .conflict(try! error.body.json)
Proposed solution
The generator should only add the throws
annotation to the computed var json
if in fact there are multiple cases/content types for that response body.
Alternatives considered
No response
Additional information
No response