Skip to content

Content negotation - "content-type" is being skipped during conversion #361

@thim81

Description

@thim81

In an OpenAPI, users will explicitly define the "content-type", since users can document multiple "content-type"s in the requests to facilitate content negotiation.

Example OpenAPI

  '/portal/v1/accounts/{accountId}':
    parameters:
         in: header
            name: content-type
            required: true
            schema:
              type: string
              example: application/json
              default: application/json
            description: Define the file type and format for the response object.

But since the latest release, the content-types gets stripped out, because of this addition in the schemaUtils.js

 // adding headers to request from reqParam
    _.forEach(reqParams.header, (header) => {
      if (!_.includes(IMPLICIT_HEADERS, _.toLower(_.get(header, 'name')))) {
        item.request.addHeader(this.convertToPmHeader(header, REQUEST_TYPE.ROOT, PARAMETER_SOURCE.REQUEST,
          components, options, schemaCache));
      }
    });

where IMPLICIT_HEADERS refers to:

// These headers are to be validated explicitly
  // As these are not defined under usual parameters object and need special handling
  IMPLICIT_HEADERS = [
    'content-type', // 'content-type' is defined based on content/media-type of req/res body,
    'accept',
    'authorization'
  ],

Can you give some insights why you want to strip out any explicitly defined content-types during the conversion from OpenAPI to Postman? Since by stripping them out, requests made to an API that explicitly validates them start to report errors.

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