nidi3 / raml-tester

Test if a request/response matches a given raml definition
Apache License 2.0
71 stars 14 forks source link

"Unrecognized token 'object': expecting true, false or null" describing json response #82

Open marcosox opened 7 years ago

marcosox commented 7 years ago

Hello, I am using raml-tester 0.9.1 to unit-test my API backend. This is the raml document:

#%RAML 1.0
title: example REST API
baseUri: http://localhost:8080/exampleBackend
version: 1.0
mediaType: application/json
/status:
  description: Reports the backend status and configuration
  get:
    responses:
      200:
        body:
          application/json:
            type: object
            properties:
              version:
                type: string
                description: application version
              frontendConfigFilename:
                type: string
                description: frontend configuration file
              baseApiUrl:
                description: base url
                type: string
              listeningIPaddress:
                description: IP address
                type: string
              listeningPort:
                description: TCP port
                type: number
              deployedVerticlesNumber:
                description: deployed verticles
                type: number
              workerPoolSize:
                description: worker pool size
                type: number
              clustered:
                description: clustered option value
                type: boolean
                required: false

However, when I run the test:

checking.path(config.getBaseApiUrl()+"/status").request().get();
Assert.assertThat(checking.getLastReport(), RamlMatchers.hasNoViolations());

It fails with this output:

java.lang.AssertionError: 
Expected: To be empty
     but: 
Response violations:
  - Body does not match schema for action(GET /status) response(200) mime-type('application/json')
    Content: {
      "Frontend_config_filename" : "frontend.properties",
      "Version" : "UNKNOWN",
      "Base_API_url" : "/exampleBackend",
      "Listening_IP_address" : "0.0.0.0",
      "Listening_port" : 8080,
      "Deployed_verticles_number" : 1,
      "Worker pool size" : 1,
      "Clustered" : false
    }
    Messages:
    - Schema invalid: Unrecognized token 'object': was expecting ('true', 'false' or 'null')
     at [Source: Inline schema definition; line: 1, column: 13]

Ignoring the fact that the error messages are "poorly documented" to say the least, I don't understand what is wrong in my schema, and I suspect it has something to do with the parser instead. Any idea?

ChristopheELIE commented 5 years ago

Hi @marcosox,

I'm currently stuck with the same issue. Did you end up finding a solution to this problem ?

marcosox commented 5 years ago

@ChristopheELIE nope, as you can see this project is unmaintained. I migrated to other solutions, sorry.

ChristopheELIE commented 5 years ago

Thank you for the quick response.

That's do damn sad. What did you use to work around this then ? I need to compare a JSON response from my API to the RAML definition (i.e. the type field in the body field) and despite this (unmaintained) project I can't seem to find one that would do what I need.

marcosox commented 5 years ago

I switched to other projects so I cannot help you with that, sorry.