stoplightio / json-schema-viewer

A JSON Schema viewer React component
Apache License 2.0
177 stars 37 forks source link

Although Supported by JSON Schema, String Array Examples Do Not Display #254

Open kentbulza opened 7 months ago

kentbulza commented 7 months ago

When examples are included for an array of strings, the examples do not display in the request body schema.

Context

Would like to display examples just like one gets for standard strings. Attached is an example OpenAPI 3.1.0. document demonstrating the issue. noarrayexamples.example.json

Current Behavior

Array examples do not display.

Expected Behavior

Would like to see array examples.

daniel-white commented 7 months ago

hey @kentbulza while this is supported in JSON Schema, but we'll take this as an enhancement request of @stoplight/json-schema-viewer. As a workaround, you can declare examples of the array itself.

{
"type": "object",
"properties": {
  "x": {
     "type": "array",
      "items": {
        "type": "string",
        "examples": ["bar"] // Don't use this example here
      },
      "examples": [["foo"], ["abc"]] // Examples here 
  }
}
}
github-actions[bot] commented 7 months ago

This ticket has been labeled jira. A tracking ticket in Stoplight's Jira (STOP-447) has been created.