Search Results for

    Show / Hide Table of Contents

    Class SerializerOptions

    serialization options for the endpoints

    Inheritance
    object
    SerializerOptions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastEndpoints
    Assembly: FastEndpoints.dll
    Syntax
    public sealed class SerializerOptions

    Properties

    CharacterEncoding

    the charset used for responses. this will be appended to the content-type header when the ResponseSerializer func is used. defaults to utf-8. set to null to disable appending a charset.

    Declaration
    public string? CharacterEncoding { set; }
    Property Value
    Type Description
    string

    EnableJsonIgnoreAttributeOnRequiredProperties

    JsonIgnoreAttribute and the required keyword cannot be typically used together with dto properties. this setting allows you to use the two together.

    Declaration
    public bool EnableJsonIgnoreAttributeOnRequiredProperties { get; set; }
    Property Value
    Type Description
    bool

    Options

    the json serializer options

    Declaration
    public JsonSerializerOptions Options { get; }
    Property Value
    Type Description
    JsonSerializerOptions

    RequestDeserializer

    a function for deserializing the incoming http request body. this function will be executed for each request received if it has a json request body. the input parameters of the func are as follows:

    HttpRequest : the incoming request
    Type : the type of the request dto which the request body will be deserialized into
    JsonSerializerContext? : json serializer context if code generation is used
    CancellationToken : a cancellation token
    Declaration
    public Func<HttpRequest, Type, JsonSerializerContext?, CancellationToken, ValueTask<object?>> RequestDeserializer { set; }
    Property Value
    Type Description
    Func<HttpRequest, Type, JsonSerializerContext, CancellationToken, ValueTask<object>>

    ResponseSerializer

    a function for writing serialized response dtos to the response body. this function will be executed whenever a json response is being sent to the client. you should set the content-type and write directly to the http response body stream in this function. the parameters of the func are as follows:

    HttpResponse : the http response object.
    object : the response dto to be serialized.
    string : the response content-type.
    JsonSerializerContext? : json serializer context if code generation is used.
    CancellationToken : a cancellation token.

    example:

    config.ResponseSerializer = (rsp, dto, cType, jCtx , ct) =>
    {
        rsp.ContentType = cType;
        return rsp.WriteAsync(Newtonsoft.Json.JsonConvert.SerializeObject(dto), ct);
    };
    Declaration
    public Func<HttpResponse, object?, string, JsonSerializerContext?, CancellationToken, Task> ResponseSerializer { set; }
    Property Value
    Type Description
    Func<HttpResponse, object, string, JsonSerializerContext, CancellationToken, Task>

    SerializerErrorsField

    this is the field name used for adding serializer errors when the serializer throws due to bad json input and the error is not concerning a particular property/field of the incoming json.

    Declaration
    public string SerializerErrorsField { set; }
    Property Value
    Type Description
    string
    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX