danielgtaylor / apisprout

Lightweight, blazing fast, cross-platform OpenAPI 3 mock server with validation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve default example based on format property

jormaechea opened this issue · comments

Summary
When mocking a request that does not provide an example, it auto-generates one based on properties data type. But it doesn't use format prop.

Steps to reproduce
Mock the following request, and call it.

/foo:
  get:
    operationId: getFoo
    responses:
      '200':
        content:
          application/json:
            schema:
              type: object
              properties:
                dateProp:
                  type: string
                  format: "date-time"

Actual result
The API response is
{"dateProp": "string"}

Expected result
{"dateProp": "2019-02-28T18:27:44-03:00"}

More info
It should also check for minLength, maxLength to provide strings; minimum, maximum, exclusiveMinimum and exclusiveMaximum to provide numbers.

Suggested string formats to be supported:

  • date
  • date-time
  • email
  • uuid

Implemented in c9362ea, though for some reason the issue didn't auto-close. New release will come soon.