question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect 'Response As JSON Object:' violation

See original GitHub issue

Given the following swagger spec:

swagger: '2.0'

info:
  version: "0.0.1"
  title: API Example

schemes:
    - "https"
basePath: /
produces:
  - application/json
consumes:
  - application/json

securityDefinitions:
  oauth2:
    type: oauth2
    flow: password
    tokenUrl: https://tokeninfo.example.com
    scopes:
      uid: Unique identifier of the user accessing the service.

security:
  - oauth2: [uid]

paths:
  '/resources':
    get:
      summary: List all resources
      responses:
        200:
          description: List of all resources.
          schema:
            type: object
            properties:
              items:
                type: array
                items:
                    '$ref': '#/definitions/Resource'
        500:
          description: Unexpected error

definitions:
  Resource:
    type: object
    properties:
      name:
        type: string

I get this violation when running the CLI:

$ cli/bin/zally swagger.yaml
Found the following MUST violations
===================================
Response As JSON Object:
	Always Return JSON Objects As Top-Level Data Structures To Support Extensibility
	/resources/GET/200

Summary:
=======
COULD violations: 0
SHOULD violations: 0
MUST violations: 1

Since the response type of /resources/GET/200 is:

{
  "items": [Resource,]
}

I would not expect it to be a violation.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mkulakcommented, Jan 5, 2017

I would like to pick that one. @fmueller are you in a process of fixing it or I can pick that?

1reaction
fmuellercommented, Jan 2, 2017

Thank you for providing us with this detailed bug description. I could reproduce the issue with your swagger example. There is also a bigger issue with this rule implementation. Fixing it will take some time. But I’m on it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix “The Response Is Not a Valid JSON ... - iThemes
Top 5 Issues Behind “The response is not a valid JSON response” Error and How to Address Them · Incorrect WordPress Site Address...
Read more >
java - JSON Object incorrect and causing HttpException
I updated the body to JSON which resulted in 2 validation errors. One was that service_id was missing and testkey was present so...
Read more >
HTTP status and error codes for JSON | Cloud Storage
The following document provides reference information about the status codes and error messages that are used in the Cloud Storage JSON API.
Read more >
Invalid JSON response — DataTables forums
The error message suggests that there is no columns information being sent to the server as part of the server-side processing request. I...
Read more >
Schema - RapidJSON
The name of each member corresponds to the JSON Schema keyword that is violated. · The value is either an object describing a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found