cancel
Showing results for 
Search instead for 
Did you mean: 
Welcome to the September Hub-bub

We are inviting you to join our exciting online event where you can learn a lot of useful information, share your knowledge and have fun. Each week, we will reward the best posters with free gift cards .

Just pick any topic you like in the SwaggerHub Community, or create your own to dive into the wonderful September Hub-bub.

Event duration: September 2-27. More information.

This Week Top Contributors:

We will decide the winners next Monday

Mock API Generation does not use data/date-time spec examples

Highlighted
New Contributor

Mock API Generation does not use data/date-time spec examples

I have an open API 3.0 spec which uses date and date time fields. 

 

I've found the API mocking integration does not use the example values in my specification.

 

For dates, the value is always 

2015-07-20

For date time it is always

2015-07-20T15:49:04-07:00

I've created a sample API which demonstrates the issue.

Below is the mocking endpoint

https://virtserver.swaggerhub.com/swilko/TestPetStoreAPI/1.0.0/store/order/1

Below is the spec examples which are specified in the spec for the Order schema, which are not returned by the mock.

 

shipDate:
type: string
format: date-time
example: "2017-07-21T17:32:28Z"
otherDate:
type: string
format: date
example: "2017-07-21"

Tags (3)
2 REPLIES 2
Moderator

Re: Mock API Generation does not use data/date-time spec examples

Hi @swilko,

 

Thanks for the details! I have reproduced the issue and forwarded it to our developers.

 

As a workaround, please add a schema-level example for the whole object - in this case the mock will use the correct date/time examples:

    Order:
      type: object
      properties:
        ...
      example:
        id: 1
        petId: 12
        qualtity: 1
        shipDate: '2017-07-21T17:32:28Z'  # <------
        otherDate: '2017-07-21'           # <------
        status: delivered
        complete: true

Helen Kosova
SmartBear Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.

Join the September Hub-bub to show off, learn and win
New Contributor

Re: Mock API Generation does not use data/date-time spec examples

Thanks for the reply, confirming the schema level example worked.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win