0

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  
tk_
  • 16,415
  • 8
  • 80
  • 90
  • 1
    Not sure this RAML is valid: there are many places where the JSON schema property is defined but is left empty. Can you do a find/replace to get rid of the empty `schema: |` properties and see if you can validate after this change? – David Dossot Oct 07 '15 at 15:56
  • But when I upload this to https://anypoint.mulesoft.com/apiplatform it do not show any errors. – tk_ Oct 07 '15 at 16:21
  • Maybe a different parser is used over there? In any case, did you try what I suggested? That would help us narrow down the issue. – David Dossot Oct 07 '15 at 16:40
  • Now I cant see the 'invalid JSON schema: no JSON Text to read from input' error message. The only error that i'm seen is 'Invalid value type'. Please find the attached screenshot in the end of the question. – tk_ Oct 07 '15 at 18:43
  • 1
    `authorizationGrants` should be a list: `authorizationGrants: [code]` See spec: https://github.com/raml-org/raml-spec/blob/master/raml-0.8.md#oauth-20 – David Dossot Oct 07 '15 at 21:09
  • Yup, it worked when I change it to list. authorizationGrants: [code] Thanks – tk_ Oct 07 '15 at 22:31
  • Excellent: I've summarized this discussion in the answer below. – David Dossot Oct 07 '15 at 22:43

1 Answers1

1

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:

  • Find/replace to get rid of the empty schema: | properties,
  • Fix authorizationGrants so it becomes a list: authorizationGrants: [code]
David Dossot
  • 33,403
  • 4
  • 38
  • 72