RAML 验证抛出 'Invalid value type'
RAML validation throws 'Invalid value type'
我尝试验证 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 依赖项。
<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>
显然在行号 :178 的 linkedin.raml 中导致了这个问题。这是为什么?
175:settings:
176: authorizationUri: https://www.linkedin.com/uas/oauth2/authorization
177: accessTokenUri: https://www.linkedin.com/uas/oauth2/accessToken
178: authorizationGrants: code
不幸的是,您正在使用的 RAML 充满了错误。它可能对应于规范的旧版本?
无论如何,解决问题:
- Find/replace 去掉空的
schema: |
属性,
- 修复
authorizationGrants
使其成为一个列表:authorizationGrants: [code]
我尝试验证 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 依赖项。
<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>
显然在行号 :178 的 linkedin.raml 中导致了这个问题。这是为什么?
175:settings:
176: authorizationUri: https://www.linkedin.com/uas/oauth2/authorization
177: accessTokenUri: https://www.linkedin.com/uas/oauth2/accessToken
178: authorizationGrants: code
不幸的是,您正在使用的 RAML 充满了错误。它可能对应于规范的旧版本?
无论如何,解决问题:
- Find/replace 去掉空的
schema: |
属性, - 修复
authorizationGrants
使其成为一个列表:authorizationGrants: [code]