Multiple Content-Types displayed under Header Parameters

Hi Team,

I am facing an issue with Header Parameters. I have with following single parameter in my swagger file.

parameters:
  - description: Request
    in: body
    name: body
    required: true
    schema:
      $ref: '#/definitions/Request'

And my definition is:

Request:
  type: object
    required:
      - name
      - city
  properties:
    name:
      default: My Name
      description: My Name
      type: string
    city:
      default: Costa Mesa
      description: My city
      type: string  

When I import it, I can see two Content-Types under Header Parameters. I had debugged it and found it multiple parameters with the Content-Types. Here is my parameters from whole model.

"parameters": [{
  "schema": null,
  "allowMultiple": null,
  "defaultValue": null,
  "dataType": "string",
  "scope": "resource",
  "name": "Content-Type",
  "options": ["application\/json"],
  "description": null,
  "type": "header",
  "items": null,
  "required": null
  },
  {
  "schema": null,
  "allowMultiple": false,
  "defaultValue": "application\/json",
  "dataType": "string",
  "scope": "method",
  "name": "Content-Type",
  "options": ["application\/json"],
  "description": "Content-Type field is to describe the data contained in the body.",
  "type": "header",
  "items": null,
  "required": true
},

I have verified the same in Edit Page where as I can see only one Content-Type under parameter section.

Am I doing something wrong here or its a bug?

Kindly help me out in resolving this issue.

Regards,

Veera

0 5 1,257
5 REPLIES 5

@Anil Sagar, Could you please check my question?

Do you have multiple values listed under "consumes" at the Swagger object level in your YAML file? For example:

swagger: '2.0'
info:
  version: 1.0.0
  ...
consumes:
  - application/json
  - application/x-www-form-urlencoded
produces:
  - application/json

I've found that a YAML file like this will cause the Content-Type header parameter to appear in all methods, with a dropdown to select from the values listed under "consumes." However, if a specific method overrides the global definition (as allowed in the OpenAPI 2.0 specification) then a request will send the allowed Content-Type, regardless of what is selected in the dropdown.

I asked a question about the Content-Type header parameter here: https://community.apigee.com/questions/41992/consumes-property-at-operation-level-does-not-over.html. Is this the same thing you're seeing?

Hi Hansen,

I have only single value under 'consumes'. Please have a look at the following.

swagger: '2.0'
host: sandbox-xx-xx.com
basePath: /xx/xx/request
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
info:
  description: Request
  title: XXX APIs
  version: 1.0.0

This is what I get in the Header Parameters.

5322-multiplecontenttypes.png

Regards,

Veera

That looks like a different issue than I experienced. Sorry, I don't think I'm able to help. Good luck.

Anybody from @apigeeteam?