Azure / api-management-developer-portal

Developer portal provided by the Azure API Management service.
MIT License
486 stars 315 forks source link

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

Closed shaluksoftint closed 6 months ago

shaluksoftint commented 10 months ago

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

2. Publish that as API to APIM
3. Go to developer portal and see API details
4. 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" }

5. Export the API definition from the Azure APIM service and check the exported yaml file.
6. 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
malincrist commented 10 months ago

Hello @shaluksoftint , thanks for reaching out! I am not able to reproduce the issue you described. For me, the value for date1 (date1: '2023-12-04') is displayed as expected in the Developer Portal definition and the downloaded definition. image

Developer Portal doesn't change the uploaded definition from Azure portal. Could you please check if, after importing this API in Azure Portal, the schema is shown correctly in the editor? You can check this from Azure Portal, after importing the API: select the API -> OpenAPI editor image

And if it the date is ok here, can you please let us know whether the issue still persist in Developer Portal?

shaluksoftint commented 10 months ago

Hello malincrist, The issue can be reproduced only after publishing the API. I am using Azure DevOps to publish the API. Thanks for getting back to me. Looking forward to hearing back from you again.

malincrist commented 10 months ago

Even after publishing, I still get the initial string ("2023-12-04", without the default time) in both developer portal and the downloaded definition. Could you please try importing this API again and check whether it still happens?

mrcarlosdev commented 6 months ago

This issue is related to managed developer portal. We advise you to create a Azure support request to get assistance on this issue. Please refer to the below link to create a new Azure support request, Please select Problem Type = "Developer Portal" in the request to route it appropriately.

https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request

mrcarlosdev commented 6 months ago

This issue is related to managed developer portal. We advise you to create a Azure support request to get assistance on this issue. Please refer to the below link to create a new Azure support request, Please select Problem Type = "Developer Portal" in the request to route it appropriately.

https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request