Skip to content

Make client serializer public #714

Open
@gao-artur

Description

@gao-artur

Describe the bug?

This should be a feature request rather than a bug, but the feature request form doesn't seem to fit, in my opinion.
I'm migrating Okta.SDK from v5.4.1 to v7.0.6. Previously, after receiving the Hook Event I used this code to deserialize it into ILogEvent objects:

private IEnumerable<ILogEvent> DeserializeEvents(JArray events)
{
    var data = new DefaultSerializer().DeserializeArray(events.ToString());
    var factory = new ResourceFactory(_oktaClient, _logger);
    return data.Select(e => factory.CreateNew<LogEvent>(e));
}

Unfortunately, since v6 it's not possible anymore.
Looking into the source code, I found that the serializer is now configured on the RestSharp client and it's not accessible from the outside

RestClient client = new RestClient(clientOptions, configureSerialization: config => config.UseOnlySerializer(() => new CustomJsonCodec(SerializerSettings, configuration)));

I'd like to request making the serializer public and not coupled to the RestSharp.

What is expected to happen?

I should be able to deserialize the Okta hook events into Okta.Sdk.Model.LogEvent using the SDK's serializer.

What is the actual behavior?

The serializer is internal and not accessible from the user code.

Reproduction Steps?

Subscribe to event hook. Deserialize the received json into the following (simplified) structure

public class EventPayload
{
    public Data Data { get; set; }
}

public class Data
{
    public JArray Events { get; set; }
}

Try deserializing the EventPayload.Data.Events to IEnumerable<Okta.Sdk.Model.LogEvent>

Additional Information?

No response

.NET Version

8.0.204

SDK Version

7.0.6

OS version

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions