Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

OAS 2 to RAML 1 conversion generates invalid '0' media type when input OAS 2 file contains single string "examples" value #52

Open
anz-rfc opened this issue Jan 16, 2019 · 0 comments

Comments

@anz-rfc
Copy link

anz-rfc commented Jan 16, 2019

observed behaviour

When an input OAS 2 file includes something of the form examples: <string> when defining a response, the resulting generated RAML 1 output file contains an invalid / fictitious media type '0' .

note, this input OAS 2 file in this scenario appears to be invalid, as the spec states that the examples value should be an object keyed by mime types. in this case, the input has a single string instead of an example object. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#exampleObject

desired behaviour

it'd be preferable if the input was rejected for being an invalid OAS 2 file, or if the invalid examples value was ignored and otherwise output was generated normally.

version of oas-raml-converter where behaviour is observed

whatever is running currently in https://mulesoft.github.io/oas-raml-converter/ at time of writing
presumably current tip of master?: cadc93e

detail

input format: OAS 2
input content:

swagger: '2.0'
info:
  description: McGuffin API
  version: 0.0.0
  title: McGuffin API
schemes:
  - http
paths:
  /mcguffin:
    get:
      operationId: GetMcGuffin
      produces:
        - application/json
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/McGuffinResponse'
          examples: blah
definitions:
  McGuffinResponse:
    type: object
    properties:
      status:
        type: string
    required:
      - status

output format: RAML 1.0
output content:

#%RAML 1.0
title: McGuffin API
description: McGuffin API
version: 0.0.0
protocols:
  - HTTP
types:
  McGuffinResponse:
    type: object
    properties:
      status:
        type: string
annotationTypes:
  oas-responses-example:
    type: string
    allowedTargets: TypeDeclaration
/mcguffin:
  get:
    displayName: GetMcGuffin
    responses:
      '200':
        description: OK
        body:
          '0':
            type: McGuffinResponse
            (oas-responses-example): h
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant