OAS: Missing media-type configuration leads to swagger converter error
Closed this issue · 0 comments
ostridm commented
Description
Converting of specification to HAR may results in error when both operation and root consumes
nodes missing. Nearly the same case for produces
configuration, converter may not take into account the root produces
configuration of the operation level configuration which overrides the root one.
Here it is required to improve converter when it handles consumes/produces
configuration.
Steps to reproduce
Pass the my-schema.yaml
(see below) to the oas2har
as follows:
import { oas2har } from '@har-sdk/oas';
import { readFile } from 'fs';
import { promisify } from 'util';
import { load } from 'js-yaml';
const content = await promisify(readFile)(
'./my-schema.yaml',
'utf8'
);
const result = oas2har(load(content) as OpenAPIV2.Document);
my-schema.yaml
swagger: '2.0'
info:
title: Future is Bright
version: 1.0.0
host: brokencrystals.com
basePath: /api/v1
schemes:
- https
paths:
'/dummy1':
post:
parameters:
- in: body
name: body
schema:
$ref: '#/definitions/requestBody'
responses:
200:
description: successful operation
schema: {}
definitions:
requestBody:
type: object
properties:
id:
type: integer
Actual result
Error produced:
contentType.split is not a function
TypeError: contentType.split is not a function
at Oas2BodyConverter.encodeValue
at Oas2BodyConverter.encodePayload
at Oas2BodyConverter.convertBody
at Oas2BodyConverter.convert
at DefaultConverter.convertPart
at DefaultConverter.createHarEntry
...
Expected result
Conversion performed successfully, application-json
media type used for content-type
header and */*
media type used for accept
header.