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

Chain of raml->oas->raml conversions produces incorrect result #517

Open
postatum opened this issue Apr 26, 2019 · 1 comment

Comments

@postatum
Copy link
Contributor

commented Apr 26, 2019

Using amf-client-js@3.1.10 with this code

const amf = require('amf-client-js')

const raml10Str = `
#%RAML 1.0
title: API with Types
types:
  User:
    type: object
    properties:
      firstName: string
      lastName:  string
      age:
        type: integer
        minimum: 0
        maximum: 125
/users/{id}:
  get:
    responses:
      200:
        body:
          application/json:
            type: User
`

async function main () {
  await amf.AMF.init()
  // RAML 1.0 string to RAML 1.0 model
  const raml10Model = await amf.AMF.raml10Parser().parseStringAsync(raml10Str)
  // RAML 1.0 model to OAS 2.0 string
  const oas20Str = await amf.AMF.oas20Generator().generateString(raml10Model)
  // OAS 2.0 string to OAS 2.0 model
  const oasModel = await amf.AMF.oas20Parser().parseStringAsync(oas20Str)
  // OAS 2.0 model to RAML 1.0 string
  const anotherRaml10Str = await amf.AMF.raml10Generator().generateString(oasModel)
  console.log(anotherRaml10Str)
}

main()

Outputs

#%RAML 1.0
types:
  User:
    type: object
    properties:
      firstName:
        type: string
        required: true
      lastName:
        type: string
        required: true
      age:
        type: integer
        minimum: 0
        maximum: 125
        required: true
title: API with Types
version: "1.0"
/users/{id}:
  get:
    responses:
      "200":
        description: ""
        body:
          application/json:
            type:
              - "#/definitions/User"
  uriParameters:
    id:
      required: true
      type: string

Note how type: User became type: - "#/definitions/User".

@BlockLucas BlockLucas added the JiraIssue label Jun 6, 2019

@BlockLucas

This comment has been minimized.

Copy link
Contributor

commented Jun 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.