Skip to content

Client configuration dateTranscoder: .iso8601WithFractionalSeconds is not used with asDecodedServerSentEventsWithJSONData #718

@ChristophM2000

Description

@ChristophM2000

Description

We do connect to a server api that sends dates with fractional seconds, so we set the dateTranscoder to .iso8601WithFractionalSeconds on the configuration struct we do pass into the Client.
This works perfectly for api calls that directly return a json result.

But some operations use server send events.
Here we use the stream.ok.body.text_event_hyphen_stream.asDecodedServerSentEventsWithJSONData(of: Components.Schemas.FooModel.self) function
which fails due to an decoding error of the date because of the fractional seconds. If I use a custom json decoder via the (of: Components.Schemas.FooModel.self, decoder: jsonDecoder) with a custom dateDecodingStrategy that uses formatOptions .withFractionalSeconds it also works here.

But shouldn't the asDecodedServerSentEventsWithJSONData function use the dateTranscoder configuration we set on the client by default?

Reproduction

You need a server api that sends server send events with a return type that contains a date formatted with fractional seconds.

let stream = try await underlyingClient.GetMessageStream()
for try await event in try stream.ok.body.text_event_hyphen_stream.asDecodedServerSentEventsWithJSONData(of: Components.Schemas.FooModel.self) {
// event.data
}

Package version(s)

.
├── swift-openapi-generatorhttps://github.com/apple/[email protected]
│ ├── swift-algorithmshttps://github.com/apple/[email protected]
│ │ └── swift-numericshttps://github.com/apple/[email protected]
│ ├── swift-collectionshttps://github.com/apple/[email protected]
│ ├── openapikithttps://github.com/mattpolzin/[email protected]
│ │ └── yamshttps://github.com/jpsim/[email protected]
│ ├── yamshttps://github.com/jpsim/[email protected]
│ └── swift-argument-parserhttps://github.com/apple/[email protected]
├── swift-openapi-runtimehttps://github.com/apple/[email protected]
│ └── swift-http-typeshttps://github.com/apple/[email protected]
└── swift-openapi-urlsessionhttps://github.com/apple/[email protected]
├── swift-openapi-runtimehttps://github.com/apple/[email protected]
│ └── swift-http-typeshttps://github.com/apple/[email protected]
├── swift-http-typeshttps://github.com/apple/[email protected]
└── swift-collectionshttps://github.com/apple/[email protected]

Expected behavior

asDecodedServerSentEventsWithJSONData function should use the dateTranscoder configuration of the client by default

Environment

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementImprovements to existing feature.status/needs-designNeeds further discussion and a concrete proposal.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions