Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make client serializer public #714

Open
gao-artur opened this issue May 15, 2024 · 2 comments
Open

Make client serializer public #714

gao-artur opened this issue May 15, 2024 · 2 comments
Labels

Comments

@gao-artur
Copy link

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

@gao-artur gao-artur added the bug label May 15, 2024
@gao-artur
Copy link
Author

Looking closer, the important part is SerializerSettings and handling nullable types.

@bryanapellanes-okta
Copy link
Contributor

@gao-artur Thanks for your request. I've added an internal issue for tracking and prioritization. OKTA-730149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants