Skip to content

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

Open
@ghost

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

  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    (t) BugBug reports (actual behavior is different than the expected behavior).(u) BackendIssues, which require changes in the developer portal's backend.(u) OpenAPI + API refIssues specific to OpenAPI support and the API reference page.P2Medium- and low-priority issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions