Default value ignored on referenced objects
When an object as a default value overridden, it doesn't show in the doc.
Here a small snippet to show the problem:
Page is defined inline (Ok: default is shown in doc) Quality1 is defined as a reference and the object has the default value inline (Ok: default is shown in doc) Quality2 is defined as a reference and the object HAS NO default value, but the default value is documented in the referring object (NOT OK: default value NOT shown in doc)
description: A test Object
type: object
properties:
page:
type: integer
default: 0
quality1:
$ref: '#/components/schemas/quality1'
quality2:
$ref: '#/components/schemas/quality2'
default: "static"
Current Behavior
The default value doesn't appear in the stoplight even if the openapi.json with version 3.1 has the default value in the property of the object "quality":
openapi.json
"quality":{"$ref":"#/components/schemas/Quality","default":"static"}
Expected Behavior
The default should appear as "static"
Here's another minimal example to illustrate the issue.
- Expected: If a parameter has a
schema.defaultthis is used as the default. -
Perhaps expected: If a parameter has a
schema.$refthat points to a component with adefault, this is used as the default. -
Perhaps expected: If a parameter has both a
schema.defaultand aschema.$refthat points to a component with adefault, the component's default overrides the parameter's default. -
NOT expected: If a parameter has both a
schema.defaultand aschema.$refthat points to a component WITHOUT adefault, the parameter's default is disregarded, and no default is shown.
{
"openapi": "3.1.0",
"paths": {
"/repro": {
"get": {
"parameters": [
{
"name": "field1",
"in": "query",
"required": false,
"schema": {
"default": "1.0"
}
},
{
"name": "field2",
"in": "query",
"required": false,
"schema": {
"$ref": "#/components/schemas/Type2"
}
},
{
"name": "field3",
"in": "query",
"required": false,
"schema": {
"$ref": "#/components/schemas/Type3",
"default": "3.0"
}
},
{
"name": "field4",
"in": "query",
"required": false,
"schema": {
"$ref": "#/components/schemas/Type4",
"default": "4.0"
}
}
]
}
}
},
"components": {
"schemas": {
"Type2": {
"default": "2.1"
},
"Type3": {
"default": "3.1"
},
"Type4": {
}
}
}
}
NOTE: I have not verified the above is a completely valid schema. But Elements does parse it, and it does demonstrate the isssue.
Elements output:
field1 any
Default: 1.0
field2 any
Default: 2.1
field3 any
Default: 3.1
field4 any