apiaryio / dredd

Language-agnostic HTTP API Testing Tool
https://dredd.org
MIT License
4.2k stars 280 forks source link

error: Error: unknown format "float" is used in schema at path "#/Foo/bar/properties/priority" #1868

Open gap777 opened 3 years ago

gap777 commented 3 years ago

Describe the bug Latest version of dredd (v14) generates an error message that was not generated with dredd v12 against OpenAPIv2 object definition referencing a float.

The following error is displayed:

error: Error: unknown format "float" is used in schema at path "#/definitions/Foo/properties/priority"
    at Object.format [as code] (/project/node_modules/gavel/build/index.js:3:68605)
    at Object.at [as validate] (/project/node_modules/gavel/build/index.js:3:33112)
    at Object.properties [as code] (/project/node_modules/gavel/build/index.js:3:85456)
    at Object.at [as validate] (/project/node_modules/gavel/build/index.js:3:33112)
    at Object.$ref [as code] (/project/node_modules/gavel/build/index.js:3:56033)
    at Object.at [as validate] (/project/node_modules/gavel/build/index.js:3:31656)
    at Object.items [as code] (/project/node_modules/gavel/build/index.js:3:74814)
    at Object.at [as validate] (/project/node_modules/gavel/build/index.js:3:33112)
    at Object.properties [as code] (/project/node_modules/gavel/build/index.js:3:85456)
    at Object.at [as validate] (/project/node_modules/gavel/build/index.js:3:33112)
    at Object.properties [as code] (/project/node_modules/gavel/build/index.js:3:85456)
    at at (/project/node_modules/gavel/build/index.js:3:33112)
    at P (/project/node_modules/gavel/build/index.js:3:35247)
    at ya.e (/project/node_modules/gavel/build/index.js:3:34914)
    at ya._compile (/project/node_modules/gavel/build/index.js:3:112414)
    at ya.validate (/project/node_modules/gavel/build/index.js:3:109157)

To Reproduce

Use this in your swagger spec

definitions:
  Foo:
    type: object
    properties:
      id:
        type: number
        example: 1000
      priority:
        type: number
        format: float
        minimum: 0.0
        maximum: 1.0
        default: 0.5

Expected behavior No error should be generated or displayed.

What's your dredd --version output?

dredd v14.0.0 (Darwin 20.1.0; x64)

Does dredd --loglevel=debug uncover something?

2020-12-03T22:55:38.387Z - debug: Processing transaction #107: Tasks > /api/v1/projects/{projectId}/foo > Bar > 200
2020-12-03T22:55:38.387Z - debug: Running 'beforeEach' hooks
2020-12-03T22:55:38.387Z - debug: Running hooks...
2020-12-03T22:55:38.387Z - debug: Running 'before' hooks
2020-12-03T22:55:38.387Z - debug: Running hooks...
2020-12-03T22:55:38.449Z - debug: Emitting to reporters: test start
2020-12-03T22:55:38.449Z - debug: Performing HTTP request to the server under test: GET http://127.0.0.1:4000/api/v1/projects/11/foo/10/bar
2020-12-03T22:55:38.502Z - debug: Handling HTTP response from the server under test
2020-12-03T22:55:38.502Z - debug: Running 'beforeEachValidation' hooks
2020-12-03T22:55:38.502Z - debug: Running 'beforeValidation' hooks
2020-12-03T22:55:38.502Z - debug: Validating HTTP transaction by Gavel.js
2020-12-03T22:55:38.510Z - debug: Gavel.js validation errored: Error: unknown format "float" is used in schema at path "#/definitions/Foo/properties/priority"
  <stack trace shown above>
 2020-12-03T22:55:38.510Z - debug: Emitting to reporters: test error
 <error shown above>
abtris commented 3 years ago

Looks as similar to https://github.com/apiaryio/dredd/issues/1879