raml-java-parser icon indicating copy to clipboard operation
raml-java-parser copied to clipboard

ResourceLocation with space character causes error when validating

Open michaelkwan opened this issue 9 years ago • 1 comments

Using version 0.8.16

List<ValidationResult> results = RamlValidationService.createDefault().validate(...);

Example: api.raml

#%RAML 0.8
title: Sample API
resourceTypes:
  - readonly: !include resourcetypes/readonly-resource.yaml

/songs:
  type: readonly
  get:

resourcetypes/readonly-resource.yaml

get:
  headers: !include ../common/headers.yaml
  responses:
    200:

common/headers.yaml

x-application-id:
  required: true

Aha! Link: https://mulesoft-roadmap.aha.io/features/APIRAML-113

michaelkwan avatar Sep 08 '16 22:09 michaelkwan

seems like the issue is there's a " " in the directory name and the it's being interpret as "%2520" when converted to URI. Use the standard java nio Path to retrieve the URI to use as the resourceLocation

Path ramlPath = Paths.get("RAML examples/api.raml");
String resourceLocation = ramlPath.getParent().toUri().toString()

the resourceLocation is

file:///absolute_path_to/RAML%20examples

Validation error message:

ValidationResult{level=ERROR, message='Include cannot be resolved file:///absolute_path/RAML%2520examples/resourcetypes/../common/headers.yaml'}

michaelkwan avatar Sep 08 '16 23:09 michaelkwan