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

OAS 2.0 to RAML 1.0 conversion generates invalid RAML when input OAS 2.0 file contains a non-top-level array type with inline items type definition #53

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

Comments

@anz-rfc
Copy link

anz-rfc commented Jan 17, 2019

input OAS 2.0 file

swagger: '2.0'
info:
  description: Foo API
  version: 0.0.0
  title: Foo API
schemes:
  - http
  - https
paths:
  /foo:
    get:
      operationId: GetFoo
      produces:
        - application/json
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/Foo'
definitions:
  Foo:
    type: object
    properties:
      barrs:
        type: array
        description: The Barrs for a single Foo
        items:
          type: object
          properties:
            name:
              type: string

Generated RAML file from oas-raml-converter:

#%RAML 1.0
title: Foo API
description: Foo API
version: 0.0.0
protocols:
  - HTTP
  - HTTPS
types:
  Foo:
    type: object
    properties:
      barrs:
        description: The Barrs for a single Foo
        type: array
        items:
          type: object
          properties:
            name:
              type: string
/foo:
  get:
    displayName: GetFoo
    responses:
      '200':
        description: OK
        body:
          application/json:
            type: Foo

I believe this generated file is not a valid RAML 1.0 file.

Note that the value for barrs: is an inline type declaration for an array type. Regarding array types, the RAML 1.0 spec states:

If you are defining a top-level array type, such as the Emails in the examples below, you can declare the following facets in addition to those previously described to further restrict the behavior of the array type.

Facet Description
items? Indicates the type all items in the array are inherited from. Can be a reference to an existing type or an inline type declaration.

(ref: https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#array-type )

My understanding is that since we are inside an inline type declaration, we are not defining a top-level array type, hence we cannot use the items facet.

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