Hello, I'm using the generator to create a client from this API:
https://github.com/griptape-ai/griptape-cloud-control-plane/blob/main/models/Griptape.openapi.json
Everything seems fine until I go to call a method. I get an error on a DateTime format mismatch in the response.
Client error - cause description: 'Unknown', underlying error: DecodingError: dataCorrupted - at : Expected date string to be ISO8601-formatted. (underlying error: <nil>),
Is there a decoder option or something I can attach to the generated client code to adjust for this?
Was able to fix w/ a transcoder: Added this to configuration
of the Client.
struct ComplainLessTranscoder: DateTranscoder {
/// Creates and returns an ISO 8601 formatted string representation of the specified date.
public func encode(_ date: Date) throws -> String { ISO8601DateFormatter().string(from: date) }
/// Creates and returns a date object from the specified ISO 8601 formatted string representation.
public func decode(_ dateString: String) throws -> Date {
let formatter = ISO8601DateFormatter()
formatter.formatOptions = [.withFractionalSeconds]
guard let date = formatter.date(from: dateString) else {
throw DecodingError.dataCorrupted(
.init(codingPath: [], debugDescription: "Expected date string to be ISO8601-formatted.")
)
}
return date
}
}
let dateTrans = ComplainLessTranscoder()