Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File unexpectedly passes validation - should complain about arrays in response #71

Closed
jamescooke opened this issue Jun 26, 2019 · 4 comments
Assignees
Labels
bug Something isn't working released

Comments

@jamescooke
Copy link
Contributor

Am running v0.12.0 installed inside a Node 12.4 Docker container.

Given the following openapi v3 spec:

openapi: 3.0.0
info:
  description: Test arrays returned
  version: '0'
  title: Things service
servers:
  - url: 'https://example.com/test'
paths:
  '/things':
    post:
      summary: Do things
      operationId: do_things
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ThingsArray'
components:
  schemas:
    ThingsArray:
      description: List of empty Things
      type: array
      items:
        type: object

This defines the response of POST /things to be an array of empty objects.

Current behaviour

The file above passes the validator with all operations post, put, patch, delete, head, options, and trace - it only fails when 'get' is used.

It also passes when imaginary operations are used: look, shut, open.

Expected behaviour

The file above should fail with:

errors

  Message :   Arrays MUST NOT be returned as the top-level structure in a response body.
  Path    :   paths./things.post.responses.200.content.application/json.schema
  Line    :   18

statistics

  Total number of errors   : 1
  Total number of warnings : 0

  errors
   1 (100%) : Arrays MUST NOT be returned as the top-level structure in a response body.

This should also happen for all other operations - real or created.

@dpopp07
Copy link
Member

dpopp07 commented Jun 26, 2019

@jamescooke Thanks for the issue. This is certainly a bug and I will look into it this week.

@dpopp07 dpopp07 self-assigned this Jun 26, 2019
@dpopp07 dpopp07 added the bug Something isn't working label Jun 26, 2019
@jamescooke
Copy link
Contributor Author

@dpopp07 Thanks for confirming 👍 It's been driving me a bit crazy this afternoon.

@dpopp07
Copy link
Member

dpopp07 commented Jun 28, 2019

Resolved in #73

@jamescooke
Copy link
Contributor Author

@dpopp07 Thanks for the quick fix on this. Just tried with v0.12.2 and it's raising errors as expected 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants