dredd icon indicating copy to clipboard operation
dredd copied to clipboard

Dredd is submitting extra request and expecting "Default" response, OAS YAML V3

Open TylerNielsen opened this issue 4 years ago • 0 comments

Describe the bug When I run Dredd against my OpenApi spec that is using OAS 3.0 YAML format, I'm finding that it's trying to validate for the response designated as "default" which we use for the non 2xx response.

In Dredd's documentation it says:

Default response is ignored by Dredd unless it is the only available response. In that case, the default response is assumed to have HTTP 200 status code.

To Reproduce Use the following OpenApi spec pasted below (save it locally), then call dredd ./openapi.yaml http://localhost:8090

Note: It's not important that we have anything running at localhost:8090, we just want to see which requests Dredd attempts to submit.

Expected behavior It should only submit one request for the "/health" endpoint, the one that is tied to the '200' response designated in the openapi spec. The "default" response should be ignored, per the dredd documentation.

What is in your dredd.yml?

openapi: 3.0.2
info:
  contact:
    email: [email protected] 
  title: Dredd Issue Example
  version: 0.0.1
  description: Demonstrates that Dredd is trying to check default responses.
tags:
  - name: Status
    description: Determines status of API.
paths:
  /health:
    get:
      tags:
        - Status
      description: Determines if service is in a healthy state.
      responses:
        '200':
          description: Valid Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthResponse'
        default:
          description: Unexpected Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      operationId: getHealth
components:
  schemas:
    HealthResponse:
      type: object
      x-tags:
        - Models
      properties:
        Status:
          type: string
          example: HEALTHY
      required:
        - Status
    Error:
      type: object
      x-tags:
        - Models
      properties:
        code:
          type: integer
          format: int32
          example: 400
        message:
          type: string
      required:
        - code
        - message

What's your dredd --version output?

V13.1.0

Does dredd --loglevel=debug uncover something? If you run Dredd with debugging output, do you see any interesting information relevant to the bug?

Nothing in the debug seems to tell me why it didn't ignore the default response.

Can you send us failing test in a Pull Request? We'll gladly help you to contribute; answering yes raises the chances the issue gets fixed. I'd be happy to try to create one, I'm just unsure the way that should be created.

TylerNielsen avatar Jun 06 '20 23:06 TylerNielsen