Validate OpenAPI response with dredd

358 Views Asked by At

I have an OpenAPI v3 specification file with the following (showing just fragments):

paths:
  /global/name:
    get:
    description: Some description
    tags:
      - Global settings
    operationId: getGlobalSettingsName
    responses:
      # Response code
      '200':
        description: Successful response
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/globalSettingsName'

components:
  schemas:
    globalSettingsName:
      type: object
      properties:
        name:
          type: integer
          description: 'ID'
          example: 1
      required:
        - name

but the server response is:

{
  "name": "somestring"
}

Note the name property type is integer and in the server response, it is a string (on purpose) but dredd request passes (success).

Doesn't dredd check for response property types?

I redefined the response as string (not JSON):

responses:
    # Response code
    '200':
      description: Successful response
      content:
        application/json:
          schema:
            type: string

and dredd doesn't complain about either.

I even changed the property of the schema:

    globalSettingsName:
      type: object
      properties:
        www:
          type: string
          description: 'some description'
          example: 'somestring'
      required:
        - www

And same (success) result when it is expected to fail.

Aren't these validation supported by dredd? Am I using specification wrong?

1

There are 1 best solutions below

1
On BEST ANSWER

It results that the current version (8.0.5) only supports example value in content: https://github.com/apiaryio/dredd/issues/1281