Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Dredd ^13.0.2 no longer supports byte format #1719

Open
rohaldb opened this issue Apr 2, 2020 · 1 comment
Open

Dredd ^13.0.2 no longer supports byte format #1719

rohaldb opened this issue Apr 2, 2020 · 1 comment
Labels
Context: validation apiaryio/gavel.js et. al

Comments

@rohaldb
Copy link

rohaldb commented Apr 2, 2020

Describe the bug
Certain string formats are no longer supported in 13.0.0.
Still working: date, date-time
No longer working: byte, password, binary

To Reproduce
I have a simple express server:

app.get('/', function(req, res) {
  res.json({message: 'Hello World!'});
})

Swagger 2.0 file api-description.yml:

swagger: '2.0'
info:
  version: '1.0'
  title: Example API
  license:
    name: MIT
host: www.example.com
basePath: /
schemes:
  - http
paths:
  /:
    get:
      produces:
        - application/json; charset=utf-8
      responses:
        '200':
          description: ''
          schema:
            type: object
            properties:
              message:
                type: string
                format: byte
            required:
              - message

Running ./node_modules/.bin/dredd with ^13.0.0 fails validation with error
Error: unknown format "byte" is used in schema at path "#/properties/message"

Expected behavior
It should validate successfully, which it does in 12.2.0

What is in your dredd.yml?

color: true
dry-run: null
hookfiles: null
language: nodejs
require: null
server: npm start
server-wait: 3
init: false
custom: {}
names: false
only: []
reporter: apiary
output: []
header: []
sorted: false
user: null
inline-errors: false
details: false
method: []
loglevel: warning
path: []
hooks-worker-timeout: 5000
hooks-worker-connect-timeout: 1500
hooks-worker-connect-retry: 500
hooks-worker-after-connect-wait: 100
hooks-worker-term-timeout: 5000
hooks-worker-term-retry: 500
hooks-worker-handler-host: 127.0.0.1
hooks-worker-handler-port: 61321
config: ./dredd.yml
blueprint: api-description.yml
endpoint: 'http://127.0.0.1:3000'

What's your dredd --version output?
13.0.2

Does dredd --loglevel=debug uncover something?
Nothing I can see

@kylef
Copy link
Member

kylef commented Jun 23, 2020

Fwiw, I don't think Dredd ever supported byte format. It's just that in prior versions of Dredd there wasn't any validation in place so Dredd didn't error out when encountering unsupported formats.

I think we can restore this behaviour by passing the unknownFormats option to AJV (the JSON Schema validation library) in Gavel (the validation library Dredd uses), as per Ajv docs:

The option unknownFormats allows changing the default behaviour when an unknown format is encountered. In this case Ajv can either fail schema compilation (default) or ignore it (default in versions before 5.0.0). You also can whitelist specific format(s) to be ignored. See Options for details.

I think this would go into https://github.com/apiaryio/gavel.js/blob/a7d1b5352291c3b360df9df5218d53c86c8b02e2/lib/validators/json-schema-next.js#L174

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Context: validation apiaryio/gavel.js et. al
Projects
None yet
Development

No branches or pull requests

2 participants