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

Method toRamlDatatype produces invalid date type format #358

Closed
postatum opened this issue Mar 6, 2020 · 2 comments
Closed

Method toRamlDatatype produces invalid date type format #358

postatum opened this issue Mar 6, 2020 · 2 comments
Labels
internal issue Internal issue created to track this case

Comments

@postatum
Copy link
Contributor

postatum commented Mar 6, 2020

Using [email protected].

Consider the code [1]. Note that method toRamlDatatype of the parsed OAS document produces RAML which is then reported as invalid by AMF. [2]

[1]

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

const schema = JSON.stringify({
  swagger: '2.0',
  info: {title: 'API with Types', version: ''},
  paths: {},
  definitions: {
    Thing: {
      $schema: 'https://json-schema.org/draft-04/schema',
      type: 'object',
      properties: {
        dateOfBirth: {
          type: 'string',
          format: 'date'
        }
      }
    }
  }
})

async function main () {
  await amf.AMF.init()
  // Parse OAS
  const oasModel = await amf.AMF.oas20Parser().parseStringAsync(schema)

  // Validate OAS
  const oasReport = await amf.AMF.validate(oasModel, amf.ProfileNames.OAS20, amf.MessageStyles.OAS)
  console.log('OAS validation report\n', oasReport.toString())

  // Generate and parse RAML
  const ramlStr = oasModel.declares[0].toRamlDatatype
  console.log('Generated RAML\n', ramlStr)
  const ramlModel = await amf.AMF.raml10Parser().parseStringAsync(ramlStr)

  // Validate RAML
  const ramlReport = await amf.AMF.validate(ramlModel, amf.ProfileNames.RAML10, amf.MessageStyles.RAML)
  console.log('RAML validation report\n', ramlReport.toString())
}

main()

[2]

OAS validation report
 Model: http://a.ml/amf/default_document
Profile: OAS 2.0
Conforms? true
Number of results: 0



Generated RAML
 #%RAML 1.0 Library
types:
  Thing:
    type: object
    additionalProperties: true
    properties:
      dateOfBirth:
        type: date-only
        format: date
        required: false



RAML validation report
 Model: http://a.ml/amf/default_document
Profile: RAML 1.0
Conforms? false
Number of results: 1

Level: Violation

- Source: http://a.ml/vocabularies/amf/aml#closed-shape
  Message: Property 'format' not supported in a RAML 1.0 shape node
  Level: Violation
  Target: http://a.ml/amf/default_document#/declarations/types/Thing/property/dateOfBirth/scalar/dateOfBirth
  Property: 
  Position: Some(LexicalInformation([(9,8)-(10,0)]))
  Location: http://a.ml/amf/default_document

Originally reported in raml-org/webapi-parser#72.

@tomsfernandez
Copy link
Contributor

Hi @postatum. I have created an internal ticket so that the team can review it.

The internal ticket is: https://www.mulesoft.org/jira/browse/APIMF-2187

@bulju bulju transferred this issue from another repository Jul 3, 2020
@nschejtman nschejtman added the internal issue Internal issue created to track this case label Jul 7, 2020
@arielmirra
Copy link
Contributor

Hi @postatum! We've fixed the issue and it will be fixed in the next release: AMF 4.5.0. I'm closing this issue. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal issue Internal issue created to track this case
Projects
None yet
Development

No branches or pull requests

4 participants