-
Notifications
You must be signed in to change notification settings - Fork 13
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
[API Proposal] Serialization Options #13
Comments
This one is a bit more involved. It also signals that the client needs to singal to the product to return pretty json. This might need to be
👍 💯, there is definitely a chance we will support a product that supports something more efficient then json in the future 🤞
👍 💯 to not put it behind an interface. The options itself are behind interfaces to support a rather complex inheritance structure.
Anything stored on That said I think it be good if only
Would force us to create a new For Then in most cases the DSL takes {
"x" : 1
"y: : {
"data": { ... user input .. }
}
} In This forces the isolation of user configured data. It's quite rare that an API only accepts user input data where The current design, heavily forces folks to decorate their |
In settings.DefaultMappingFor<MyDerivedDocument>(d => d
.PropertyName(p => p.IntProperty, nameof(MyDerivedDocument.IntProperty))
.Ignore(p => p.StringProperty)
); Wonder if it would be worth investigating shipping |
NOTE: This API proposal is a work in progress and open to change. This acts as a phase one suggestion which may require some prototyping to finalise.
Background and Motivation
From a usability standpoint, I would like to explore whether it would be helpful to expose configuration optionS that allow users to control serialization/deserialization of requests without having to implement the
ITransportSerializer
interface themselves.Scenarios where this may be helpful include where users need to control the casing for serialized keys in the final JSON when using the low-level client. This doesn't seem to be simple with the current design.
Currently, the design allows
PrettyJson
to be specified on theITransportOptions
. I would propose we move options related to serialization into their own type (possibly with an interface defining the structure).Proposed API
Our configuration options can act as a facade over common configuration options for generalised serializers. We should aim to keep this reasonably agnostic to the serializer being used and try to ensure that options are generally applicable on all serializers.
This allows us to remove serialization related properties from the
ITransportConfiguration
.We can also remove the fluent syntax method for the above located on
TransportConfigurationBase
.Serializers may then accept the options into the ctor and apply the values as neccesary when serializing/deserializing.
I suspect we may want to provide helpers to simplify setting up the default serializer with options.
We could also enable per request control of serialization by accepting an
ITransportSerializerOptions
into theSerializable<T>
static method. When present, these options are applied in preference to any defined on the serializer directly.The internal implementation could then use the provided options for the specific request. While perhaps less common, this would support codebases which interact with different indexes through a single client, where those indexes differ in their casing rules.
Usage Examples
TODO
Further Considerations
PrettyJson
could perhaps bePrettySerialization
.ITransportSerializerOptions
interface, or would theTransportSerializerOptions
type be sufficient? Consider future additions and the impact on versioning this. Will users realistically need to mock it?TransportSerializerOptions
type to be immutable?The text was updated successfully, but these errors were encountered: