Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAS: Missing media-type configuration leads to swagger converter error #210

Closed
ostridm opened this issue Sep 18, 2023 · 0 comments · Fixed by #211
Closed

OAS: Missing media-type configuration leads to swagger converter error #210

ostridm opened this issue Sep 18, 2023 · 0 comments · Fixed by #211
Assignees
Labels
Type: bug Something isn't working.

Comments

@ostridm
Copy link
Contributor

ostridm commented Sep 18, 2023

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.

@ostridm ostridm added the Type: bug Something isn't working. label Sep 18, 2023
@ostridm ostridm self-assigned this Sep 18, 2023
@ostridm ostridm changed the title Missing media-type configuration leads to converter error OAS: Missing media-type configuration leads to swagger converter error Sep 18, 2023
ostridm added a commit that referenced this issue Sep 18, 2023
ostridm added a commit that referenced this issue Sep 18, 2023
ostridm added a commit that referenced this issue Sep 18, 2023
ostridm added a commit that referenced this issue Sep 19, 2023
ostridm added a commit that referenced this issue Sep 19, 2023
ostridm added a commit that referenced this issue Sep 20, 2023
ostridm added a commit that referenced this issue Sep 20, 2023
ostridm added a commit that referenced this issue Sep 20, 2023
ostridm added a commit that referenced this issue Sep 20, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
ostridm added a commit that referenced this issue Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: bug Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant