mavenyamlramlraml-java-parser

RAML validation throws 'Invalid value type'


I try to validate linkedin.raml but I got below set of validation errors for some reason.

[2015-10-07 00:09:46,776] ERROR {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  Invalid value type
[2015-10-07 00:09:46,778]  WARN {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  schema can not be empty
[2015-10-07 00:09:46,778] ERROR {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  invalid JSON schema: no JSON Text to read from input
[2015-10-07 00:09:46,778]  WARN {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  example can not be empty
[2015-10-07 00:09:46,778]  WARN {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  schema can not be empty
[2015-10-07 00:09:46,778] ERROR {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  invalid JSON schema: no JSON Text to read from input
[2015-10-07 00:09:46,778]  WARN {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  example can not be empty
[2015-10-07 00:09:46,778]  WARN {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  schema can not be empty
[2015-10-07 00:09:46,778] ERROR {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  invalid JSON schema: no JSON Text to read from input
[2015-10-07 00:09:46,778]  WARN {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  example can not be empty
[2015-10-07 00:09:46,778]  WARN {org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor} -  schema can not be empty
...

Below is the code snippet I used to validate RAML

private boolean isValidRAML(String sourceUrl) {
        boolean isNoError = true;

        List<ValidationResult> results = RamlValidationService.createDefault().validate(sourceUrl);
        Iterator<ValidationResult> resultsIterator = results.iterator();
        while (resultsIterator.hasNext()) {
            ValidationResult valResult = resultsIterator.next();
            String resultLevel = valResult.getLevel().toString();
            String resultMessage = valResult.getMessage();
            if (CommonConstantsRAML.ERROR_PARAMETER_NAME.equals(resultLevel)) {
                log.error(resultMessage);
                isNoError = false;
            } else if (CommonConstantsRAML.WARN_PARAMETER_NAME.equals(resultLevel)) {
                log.warn(resultMessage);
            }
        }

        return isNoError;
    }

Is this expected? if not what is causing this? for more reference kindly find set of mvn dependancies I have used in my orbit bundle.

<dependencies>
        <dependency>
            <groupId>org.raml</groupId>
            <artifactId>raml-parser</artifactId>
            <version>0.8.11</version>
            <exclusions>
                <exclusion>  
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>
            </exclusions> 
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.logging</artifactId>
            <version>4.2.0</version>
        </dependency>
    </dependencies>

enter image description here

Apparently in the linkedin.raml at line number :178 causing this issue. Why is this?

175:settings:
176:        authorizationUri: https://www.linkedin.com/uas/oauth2/authorization
177:        accessTokenUri: https://www.linkedin.com/uas/oauth2/accessToken
178:        authorizationGrants: code  

Solution

  • The RAML you're using is unfortunately littered with error. It may correspond to an old version of the spec?

    Anyways, to fix the issues: