Skip to content

Consumes in global context is not propagated to the request body #400

@PerthCharern

Description

@PerthCharern

consumes in global context is not propagated to the request body

We need to fix it in a similar way to how we fixed produces in #267 and #398.

{
    "swagger": "2.0",
    "info": {
        "title": "Two responses",
        "version": "1.0.0"
    },
    "schemes": [
        "https"
    ],
    "basePath": "/",
    "paths": {
        "/items": {
            "post": {
                "responses": {
                    "200": {
                        "description": "An OK response",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/Item"
                            }
                        }
                    },
                    "default": {
                        "description": "An error response",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "name",
                        "in": "formData",
                        "description": "Updated name of the pet",
                        "required": false,
                        "type": "string"
                    }
                ]
            },
            "patch": {
                "responses": {
                    "200": {
                        "description": "An OK response",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/Item"
                            }
                        }
                    },
                    "default": {
                        "description": "An error response",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                },
                "produces": [
                    "application/json",
                    "application/xml"
                ],
                "consumes": [
                    "application/json",
                    "text/plain"
                ],
                "parameters": [
                    {
                        "name": "name",
                        "in": "formData",
                        "description": "Updated name of the pet",
                        "required": false,
                        "type": "string"
                    }
                ]
            }
        }
    },
    "produces": [
        "application/json"
    ],
    "consumes": [
        "application/json"
    ],
    "definitions": {
        "Item": {
            "properties": {
                "id": {
                    "type": "string",
                    "description": "Item identifier."
                }
            }
        },
        "Error": {
            "properties": {
                "code": {
                    "type": "integer",
                    "format": "int32"
                },
                "message": {
                    "type": "string"
                },
                "fields": {
                    "type": "string"
                }
            }
        }
    }
}

With the above document, the media type added to POST does not respect the "application/json" defined in the global level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugA broken experience

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions