8000 Behavior change in format listener configuration · Issue #1205 · FriendsOfSymfony/FOSRestBundle · GitHub
[go: up one dir, main page]

Skip to content

Behavior change in format listener configuration #1205

@aledeg

Description

@aledeg

I updated the bundle recently and I found a discrepancy in the behavior of my API.

Here is my configuration:

fos_rest:
    routing_loader:
        include_format: false
    view:
        formats:
            json: ~
            xml: ~
        view_response_listener: force
    format_listener:
        rules:
          - { path: '^/api', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: false }
          - { path: '^/', stop: true }

Before the update, I received JSON response when I asked for JSON ("Accept: application/json") and I received XML response when I asked for XML ("Accept: application/xml").
After the update, I received JSON response no matter what I asked for.

Basically, it was because when I asked for XML, I got the fallback instead. I figured that the problem was with the mime-type extraction process and I changed my configuration to the following:

fos_rest:
    routing_loader:
        include_format: false
    view:
        formats:
            json: ~
            xml: ~
        view_response_listener: force
    format_listener:
        rules:
          - { path: '^/api', priorities: ['json', 'xml', 'application/xml'], fallback_format: json, prefer_extension: false }
          - { path: '^/', stop: true }

I found that the mime-type for XML was transformed to text/xml thus not matching the value in my header (application/xml).

My actual commit is 82b8388.
My previous commit was 9fe38af

Is that behavior normal? Is this a bug?

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

      0