api-management-developer-portal icon indicating copy to clipboard operation
api-management-developer-portal copied to clipboard

Developer portal and exported yaml file display incorrect values in the examples payload for the date field

Open shaluksoftint opened this issue 1 year ago • 3 comments

Bug description

When an API is published with a date field of type: string and format: date, developer portal and the exported yaml file display incorrect values in the examples payload for the date field.

Reproduction steps

  1. Create following product.yaml file:
openapi: "3.0.1"
info:
  title: Product 
  version: "1.0"

paths:
  /:
    post:
      requestBody:
        description: My request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductPayload'
            examples:
              Example 1:
                value:
                  id: 1
                  name: My Name
                  date1: '2023-12-04'
      responses:
        "200":
          description: OK response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductPayload"
              examples:
                Example 1:
                  value:
                    id: 1
                    name: My Name
                    date1: '2023-12-04'             
components:
  schemas:
    ProductPayload:
      description: Product Payload
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        date1:
          type: string
          format: date
  1. Publish that as API to APIM
  2. Go to developer portal and see API details
  3. Incorrect date value is shown for date1 field for the request and response examples:
{
    "id": 1,
    "name": "My Name",
    "date1": "2023-12-04T01:00:00Z"
}
  1. Export the API definition from the Azure APIM service and check the exported yaml file.
  2. The exported yaml file has incorrect date values in the examples for request and response payloads as shown:
openapi: "3.0.1"
info:
  title: Product 
  version: "1.0"

paths:
  /:
    post:
      requestBody:
        description: My request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductPayload'
            examples:
              Example 1:
                value:
                  id: 1
                  name: My Name
                  date1: '2023-12-04T01:00:00.0000000+00:00'
      responses:
        "200":
          description: OK response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductPayload"
              examples:
                Example 1:
                  value:
                    id: 1
                    name: My Name
                    date1: '2023-12-04T01:00:00.0000000+00:00'         
components:
  schemas:
    ProductPayload:
      description: Product Payload
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        date1:
          type: string
          format: date

Expected behavior

As the date1 field has type: string and format: date in the schema definition, example payloads for the request and response in the developer portal and the exported yaml file should have only date, not the time component.

Examples in the developer portal should display:

{
    "id": 1,
    "name": "My Name",
    "date1": "2023-12-04"
}

Examples in the exported yaml file should have:

Example 1:
  value:
    id: 1
    name: My Name
    date1: '2023-12-04'

Is your portal managed or self-hosted?

Managed

Release tag or commit SHA (if using self-hosted version)

N/A

API Management service name

cs-uks-api-uat-apim

Environment

  • Operating system: macOS - Venture 13.6.2
  • Browser: Google Chrome
  • Version: Version 119.0.6045.199 (Official Build) (arm64)

Additional context

N/A

shaluksoftint avatar Dec 04 '23 06:12 shaluksoftint