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

Does the parser support RAML 1.0 Library modules? Is it planned to support it? #100

@tomaszstec

Description

@tomaszstec

Library version used
"0.5.0"

Language library used with
Java

Describe the issue
I have a modular RAML that contain RAML libraries. I tried to use the parser to handle it but it failed. Does the webapi-parser support RAML libraries? Is it planned to support

Input you have issues with
The validation of following RAML always fails.
File: api.raml

#%RAML 1.0
title: My API
baseUri:
  value: "https://{host}:{port}/b2c"
baseUriParameters:
  port:
    type: number
    #description: Port
  host:
    type: string
    #description: Host

uses:
  errorTraits: errorTraits.raml
  loginTypes: types/errorTypes.raml

/login:
  securedBy:
  post:
    is: [ errorTraits.login ]
    description: Authorize member and issue access token.
    body:
      application/x-www-form-urlencoded:
        type: loginTypes.LoginRequest
    responses:
      200:
        body:
          application/json:
            type: loginTypes.LoginResponse

File: errorTraits.raml

#%RAML 1.0 Library
traits:
  login:
    responses:
      401:
        description: List of error codes
        body:
          application/json:
            type: object

File: types.raml

#%RAML 1.0 Library
types:
  LoginRequest:
    type: object
    properties:
      username:
        type: string
        description: member's login
      password:
        type: string
        description: member's password
  LoginResponse:
    type: object
    properties:
      access_token:
        type: string
        description: access token which can be provided in Authorization header
      refresh_token:
        type: string
        description: long living token which can be used to issue new access_tolen

Code you have issues with

WebApiBaseUnit base = Raml10.parse('url-string-to-api.raml').get();
WebApiBaseUnit resolved = Raml10.resolve(base).get();
ValidationReport validationReport = Raml10.validate(resolved).get();
if (!validationReport.conforms()) {
            throw new ApplicationException(RamlErrors.VALIDATION_ERROR, validationReport.toString());
}
WebApiDocument apiDocument = (WebApiDocument)resolved;
WebApi api = (WebApi)apiDocument.encodes();
log.debug(api.endPoints().stream().map (endpoint-> endpoint.name()).collect(Collectors.joining("\n")));

Actual behaviour/output/error

Model: file:///D:/GIT/my-project/src/main/resources/api.raml
Profile: RAML 1.0
Conforms? false
Number of results: 2

Level: Violation

- Source: http://a.ml/vocabularies/amf/core#unresolved-reference
  Message: Unresolved reference 'loginTypes.LoginRequest'
  Level: Violation
  Target: file:///D:/GIT/my-project/src/main/resources/api.raml#/web-api/end-points/%2Flogin/post/request/application%2Fx-www-form-urlencoded/any/schema/unresolved
  Property: 
  Position: Some(LexicalInformation([(24,14)-(24,37)]))
  Location: file:///D:/GIT/my-project/src/main/resources/api.raml

- Source: http://a.ml/vocabularies/amf/core#unresolved-reference
  Message: Unresolved reference 'loginTypes.LoginResponse'
  Level: Violation
  Target: file:///D:/GIT/my-project/src/main/resources/api.raml#/web-api/end-points/%2Flogin/post/200/application%2Fjson/any/schema/unresolved
  Property: 
  Position: Some(LexicalInformation([(29,18)-(29,42)]))
  Location: file:///D:/GIT/my-project/src/main/resources/api.raml

Expected behaviour/output
No validation errors. API model should be returned. List of endpoint names should be logged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions