Dredd: Open API 3.0.0 query parameter example value is set but is not used.

Created on 11 Feb 2019  路  3Comments  路  Source: apiaryio/dredd

Describe the bug
I'd like to use dredd with Open API 3.0.0.
Query parameter example value is set but is not used.

To Reproduce

I have Open API 3.0.0 schema (this is just minimal working example):

info:
  title: 'Title'
  version: 1.0.0
openapi: 3.0.0
paths:
  /check-code:
    get:
      parameters:
        -
          name: code
          in: query
          required: true
          description: 'SMS code to check'
          schema:
            type: string
            example: XYZ
      responses:
        200:
          description: 'Info about requested code'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      code:
                        type: string
                      used_at:
                        type: string
                        format: date-time
                        nullable: true
                    required:
                      - code
                      - used_at
                    additionalProperties: false
                required:
                  - data
                additionalProperties: false
                example:
                  data:
                    code: XYZ
                    used_at: null

saved as json in file api.json:

{"info":{"title":"Title","version":"1.0.0"},"openapi":"3.0.0","paths":{"/check-code":{"get":{"summary":"Check SMS code","description":"Checks SMS code. Always returns code from request, date of usage or null and referenced payment or null.","parameters":[{"name":"code","in":"query","required":true,"description":"SMS code to check","schema":{"type":"string","example":"XYZ"}}],"responses":{"200":{"description":"Info about requested code","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"code":{"type":"string"},"used_at":{"type":"string","format":"date-time","nullable":true}},"required":["code","used_at"],"additionalProperties":false}},"required":["data"],"additionalProperties":false,"example":{"data":{"code":"XYZ","used_at":null}}}}}}}}}}}

I am trying to execute command:
dredd api.json "http://localhost:7890/api/v1" -l debug -h

Expected behavior
I expect dredd to call mentioned API endpoint with example value:

http://localhost:7890/api/v1/check-code?code=XYZ

What is in your dredd.yml?

I don't use dredd.yml

What's your dredd --version output?

dredd v8.0.0 (Linux 4.15.0-45-generic; x64)

Does dredd --loglevel=debug uncover something?
I think these lines are the most important:

2019-02-11T21:34:36.843Z - warn: Parser warning in file 'http://localhost:7890/api/v1/docs/open-api': 'Schema Object' contains unsupported key 'example' on line 1
2019-02-11T21:34:36.843Z - error: Compilation error in file 'http://localhost:7890/api/v1/docs/open-api': Required URI parameter 'code' has no example or default value. ( > /platba-mobilom/check-code > Check SMS code)

First marked example as unsupported key and the second is searching for example or default value.

Maybe unsupported means this is not a bug but feature request?

Can you send us failing test in a Pull Request?
Mentioned above

OpenAPI 3

Most helpful comment

I think we can close this issue. Maybe I will try to add schema.example to OAS3 parser too.

All 3 comments

@lulco Thanks for the issue! The warning is from the OAS3 parser and means the example key is not supported yet. The error comes from Dredd as it needs an example value.

We're working on improving the parser every day, but you can help us to speed things up by contributing. It should be a matter of making additions to this directory in accordance with the contributing guide.

I believe we should move this issue here.

I think we can close this issue. Maybe I will try to add schema.example to OAS3 parser too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

honzajavorek picture honzajavorek  路  4Comments

DavidFaizulaev picture DavidFaizulaev  路  5Comments

yourithielen picture yourithielen  路  5Comments

honzajavorek picture honzajavorek  路  6Comments

marc0l92 picture marc0l92  路  4Comments