RAML验证会抛出“无效的值类型”'

时间:2015-10-07 07:14:33

标签: maven yaml raml raml-java-parser

我尝试验证linkedin.raml但由于某种原因我得到了以下验证错误集。

[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
...

以下是我用来验证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;
    }

这是预期的吗?如果不是造成这种情况的原因?为了更多的参考,请查看我在我的轨道包中使用的一组mvn dependancies。

<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

显然在linkedin.raml行号:178导致此问题。这是为什么?

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

1 个答案:

答案 0 :(得分:1)

不幸的是,您正在使用的RAML出现了错误。它可能对应于旧版本的规范?

无论如何,要解决问题:

  • 查找/替换以删除空的schema: |属性
  • 修复authorizationGrants,使其成为一个列表:authorizationGrants: [code]