OpenAPI schemas: 'date' format shows same as 'date-time'
See original GitHub issueBug description
Developer portal shows example data for date
fields regardless of their format
.
Reproduction steps
- Create following
product.yaml
file:
openapi: "3.0.2"
info:
title: Products
version: "1.0"
components:
schemas:
product:
description: Product
type: object
properties:
id:
type: integer
name:
type: string
date1:
type: string
format: date
example: "2020-06-25"
date2:
type: string
format: date-time
example: "2020-07-25T12:34:56Z"
paths:
/:
get:
responses:
"200":
description: OK response
content:
application/json:
schema:
$ref: "#/components/schemas/product"
Notice difference in format
and example
fields:
date1:
type: string
format: date
example: "2020-06-25"
date2:
type: string
format: date-time
example: "2020-07-25T12:34:56Z"
- Publish that as API to APIM
- Go to developer portal and see API details
- Incorrect format is shown for
date1
field:
{
"id": 0,
"name": "string",
"date1": "2020-06-25T00:00:00",
"date2": "2020-07-25T12:34:56+00:00"
}
Expected behavior
In above json date1
field should be 2020-06-25
as per string formats.
Expected output would be:
{
"id": 0,
"name": "string",
"date1": "2020-06-25",
"date2": "2020-07-25T12:34:56+00:00"
}
Is your portal managed or self-hosted?
Self-hosted
Release tag or commit SHA (if using self-hosted version)
N/A
API Management service name
demo9001
Environment
- Operating system: Windows 10
- Browser: Edge
- Version: Version 86.0.622.3 (Official build) dev (64-bit)
Additional context
N/A
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
What is the correct way to declare a date in an OpenAPI ...
Use format: date and don't use pattern , much easier to read. If you do want to use a regex for a different...
Read more >Dates in OpenAPI Files | Baeldung
In this case, we used the date format to describe the createdAt date. This format describes dates using the ISO 8601 full-date format....
Read more >Data Types - Swagger
OpenAPI defines the following built-in string formats: date – full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21.
Read more >Non-Standard Date and Time Formats | by John Wang - Medium
Non-standard APIs actually cause interoperability problems because the OpenAPI 3.0 and Swagger 2.0 API specifications only support RFC-3339 ...
Read more >Parse and Format Date Function Calls | Mendix Documentation
For example parseDateTime('35-11-2015', 'dd-MM-yyyy', dateTime(2015)) will return 05 December 2015 12:00 AM . 2.3 Example. The examples below illustrate which ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue seems to be root-caused on the API Management side. If you add the above product.yaml as a new Open API in the portal and then click the ‘Open the OpenAPI editor (YAML)’ from the management portal, you’ll get the following outcome including the date-time problem:
However, the most visible outcome is that end users (aka. api developers) can’t use the dev portal’s Try it -functionality without first going through all dates and fixing the manually every time.
This happens on the managed API Management service.
Hi, Any news on the deployment of the fix? Thanks