raml-java-parser
raml-java-parser copied to clipboard
ResourceLocation with space character causes error when validating
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
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'}