scalar / scalar

Scalar is an open-source platform with:                                       🌐 Modern Rest API Client                                        📖 Beautiful API References                                        ✨ 1st-Class OpenAPI/Swagger Support
https://scalar.com
MIT License
6.37k stars 203 forks source link

[AspNetCore.Scalar] Schema Transformers Example Values Not Displayed in Scalar UI #3381

Open w1am opened 5 days ago

w1am commented 5 days ago

What happens?

When using Schema Transformation to set example values for properties in a dynamic Settings object, the example does not appear in the Scalar UI test request body form. The OpenAPI document generated from the application (available at /openapi/v1.json) correctly displays the example when viewed in Swagger Editor. However, in Scalar UI, the example value for the Endpoint property is not shown in the request body form used for testing.

What did you expect to happen?

I expected the example values set for the Settings object, for the Endpoint property, to appear in the Scalar UI test request body form, similar to how they are correctly displayed in the Swagger Editor. This would provide users with predefined example data for the request body during testing.

Example is being shown in code snippet but not in the test request modal form image

image

Expected image

How it's being displayed in Swagger

image

OpenAPI Document

{
  "openapi": "3.0.1",
  "info": {
    "title": "ReproduceScalarIssue | v1",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "http://localhost:5029"
    }
  ],
  "paths": {
    "/settings": {
      "post": {
        "tags": [
          "ReproduceScalarIssue"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Settings"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IResult"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "IResult": {
        "type": "object"
      },
      "Settings": {
        "type": "object",
        "properties": {
          "Endpoint": {
            "type": "string",
            "description": "The URL or endpoint to which the request or message will be sent.",
            "example": "https://www.github.com"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "ReproduceScalarIssue"
    }
  ]
}

To reproduce, copy this document in Scalar UI playground and in Swagger editor and compare the difference.

Reproducible Repo

https://github.com/w1am/ReproduceScalarIssue

xC0dex commented 5 days ago

This might be related to the problems reported in #3373 and #3242.