-
Couldn't load subscription status.
- Fork 314
Description
In OpenAPI 3.1.0, the example schema keyword is deprecated in favor of the examples keyword from JSON Schema. RapiDoc ignores the examples keyword in some contexts, which causes it to omit schema-provided examples from its output entirely in some cases, unless they are provided via the deprecated keyword.
NOTE: I've created a PR to address this problem here: #1065
Reproduction and Impact
- Open
openapi-spec-minimal.json(included at the end of this issue) via the "LOCAL JSON FILE" button at https://rapidocweb.com/examples/example1.html - Expand
POST /api/test - Look at the
EXAMPLEin theRESPONSEsection
Actual behavior:
{
"list_field": [
"string"
],
"list_field_single_example": [
"Deprecated but included in output"
],
"string_field": "Included in output"
}Note [ "string" ] under list_field.
Expected behavior:
{
"list_field": [
"Bug: missing from output"
],
"list_field_single_example": [
"Deprecated but included in output"
],
"string_field": "Included in output"
}Note [ "Bug: missing from output" ] under list_field.
Note that this expected behavior is also present when using https://editor-next.swagger.io/
Minimal Schema
openapi-spec-minimal.json:
{
"openapi": "3.1.0",
"info": {
"title": "Test API",
"version": "0.0.1",
"description": "Minimal test"
},
"paths": {
"/api/test": {
"post": {
"parameters": [],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"properties": {
"list_field": {
"description": "List of Strings",
"examples": [["Bug: missing from output"]],
"items": { "type": "string" },
"type": "array"
},
"list_field_single_example": {
"description": "List of Strings single example",
"example": ["Deprecated but included in output"],
"items": { "type": "string" },
"type": "array"
},
"string_field": {
"description": "String Field",
"examples": ["Included in output", "Missing from output since only one example is displayed"],
"type": "string"
}
},
"required": [
"list_field",
"string_field"
],
"title": "Demo",
"type": "object"
}
}
}
}
}
}
}
}
}Note that this schema validates using https://editor-next.swagger.io/, but the example field is shown as deprecated, as expected.