Azure / Azure/api-management-developer-portal

Example time format changes to date-time if schema referenced through $ref

Open
#1,574 5 comments 1 reaction 0 assignees View on GitHub
(t) Bug (u) Backend (u) OpenAPI + API ref P2
Dominant language
TypeScript
Stars
545
Forks
360
PR merge metrics
No merged PRs in 30d

Description

When importing API through the developer portal / azure cli / azure PowerShell, example fields with format set to `time` are changed to full date-time if the example schema is referenced by `$ref`.

## Reproduction steps

1. Import the following API specification:
```
openapi: 3.0.3
info:
title: Time Format Test
description: Time Format Test
version: 1.0.0
servers:
- url: 'https://example.com'
paths:
/without-schema:
post:
summary: POST ISO time
operationId: post-iso-time
requestBody:
content:
application/json:
schema:
type: object
properties:
time:
type: string
format: time
example:
time:
'10:00:00+01:00'
responses:
200:
description: OK

/with-schema:
post:
summary: POST ISO time with Schema
operationId: post-iso-time-w-schema
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/IsoTime'
example:
time:
'10:00:00+01:00'
responses:
200:
description: OK

components:
schemas:
IsoTime:
type: object
properties:
time:
type: string
format: time

```
2. Navigate to the imported API. Check the operations generated body in the _Test_ tab.

## Expected behavior

Both operations should have the following body:
```
{"time":"10:00:00+01:00"}
```

## Actual behavior:

The body of the _POST ISO time with Schema_ operation is:
```
{"time":"2021-12-16T09:00:00Z"}
```
It has been converted from ISO time to ISO date-time in UTC.

This issue prevents users from testing the API with the provided example, as the backend service expects a _time_, not _date-time_ property.

This issue affects also _Azure CLI_, _APIM REST API_ and _Azure PowerShell_.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by importing the provided OpenAPI specification and comparing the generated Test-tab bodies for the two operations. Trace how the referenced IsoTime schema and its example are processed, then verify that the $ref case preserves "10:00:00+01:00" instead of converting it to date-time.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.