Skip to content

Dot not run json:api registered json serialization when content-type header is null.Β #596

Closed
@theandrewcosta

Description

@theandrewcosta

Description

I have a situation where I would like to serialize json responses for NON json:api endpoints in a different way than for that of json:api endpoints.

As it stands now, the json:api library registers an IOutputFormatter that is called for json serialization when the content type is null or it equals the "application/vnd.api+json" content type.

return string.IsNullOrEmpty(contentTypeString) || contentTypeString == Constants.ContentType;

This might be ok for most situations, but in our situation, we don't use json:api for all endpoints that return json payloads.

Would it not make most sense to run the json serialization code registered by the json:api library only when requests come in with content type or accept header with the value "application/vnd.api+json"?

We've had to fork the library and make modifications to JsonApiOutputFormatter.cs so that the json serialization registered by the json:api library is not run (and therefore are default serialization code is run) when the content-type header is null.

Environment

  • JsonApiDotNetCore Version: 3.1.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions