Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

When converting RAML -> OAS2, inheritance information is lost #74

Description

@skingreek

I try convert my RAML to OAS2 for use it for viewing in ReDoc project.
Result file not contains valid information about inherent relationship:
User is Person and Employee is Person

I use simple code:

    final WebApiBaseUnit result = Raml10.parse("file://../api-specs/raml/discrTest.raml").get();
    Oas20.generateYamlFile(result, "file://oas2_out.yaml").get();

discrTest.raml contains:

#%RAML 1.0
title: My API With Types
types:
  Person:
    type: object
    discriminator: kind # refers to the `kind` property of object `Person`
    properties:
      kind: string # contains name of the kind of a `Person` instance
      name: string
  Employee: # kind can equal `Employee`; default value for `discriminatorValue`
    type: Person
    properties:
      employeeId: integer
  User: # kind can equal `User`; default value for `discriminatorValue`
    type: Person
    properties:
      userId: integer

/resource:
  get:
    responses:
      200:
        body:
          application/json:
            type: Person

As result oas2_out.yaml contains:

swagger: "2.0"
info:
  title: My API With Types
  version: "1.0"
paths:
  /resource:
    get:
      responses:
        "200":
          description: ""
          x-amf-mediaType: application/json
          schema:
            type: object
            x-amf-merge:
              -
                $ref: "#/definitions/Person"
definitions:
  Person:
    type: object
    discriminator: kind
    required:
      - kind
      - name
    properties:
      kind:
        type: string
      name:
        type: string
  Employee:
    type: object
    required:
      - employeeId
    properties:
      employeeId:
        type: integer
    x-amf-merge:
      -
        $ref: "#/definitions/Person"
  User:
    type: object
    required:
      - userId
    properties:
      userId:
        type: integer
    x-amf-merge:
      -
        $ref: "#/definitions/Person"

But i expect like this:

swagger: '2.0'
info:
  title: My API With Types
  version: ''
definitions:
  Person:
    discriminator: kind
    type: object
    properties:
      kind:
        type: string
      name:
        type: string
    required:
      - kind
      - name
  Employee:
    allOf:
      - $ref: '#/definitions/Person'
      - properties:
          employeeId:
            type: integer
        required:
          - employeeId
        type: object
  User:
    allOf:
      - $ref: '#/definitions/Person'
      - properties:
          userId:
            type: integer
        required:
          - userId
        type: object
paths:
  /resource:
    get:
      operationId: GET_resource
      produces:
        - application/json
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/Person'

Activity

  1. postatum commented on Mar 13, 2020

    @postatum
    Contributor

    Hi @skingreek.

    Sorry for the inconvenience. The issue you face come from a dependency lib we use. I've reported it to that lib team.

    If it helps, you can "resolve" your RAML document and then generate OAS.

    Docs on resolution: https://raml-org.github.io/webapi-parser/resolving.html
    Example here.

  2. added
    amfRelated to AMF issue, bug or specific behavior
    on Mar 13, 2020
  3. added
    bugSomething isn't working
    questionFurther information is requested
    and removed
    bugSomething isn't working
    on Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    amfRelated to AMF issue, bug or specific behaviorquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions