Describe the bug
In OpenAPI.NET 3.4, unevaluatedProperties: false is emitted on schemas
whose type is not object, for example arrays and primitive types.
Example:
"EmployeeList": {
"unevaluatedProperties": false,
"type": "array",
"items": {
"$ref": "#/components/schemas/EmployeeResponse"
},
"description": "List of employees."
}
unevaluatedProperties is only meaningful for object schemas. When
emitted on an array, string, number, integer, boolean, or null schema,
it has no effect and appears to be serializer noise.
Expected behavior
unevaluatedProperties should only be serialized when the schema is an
object schema, or otherwise when it can actually apply to object
validation.
Example (valid usage):
{
"type": "object",
"properties": {
"name": { "type": "string" }
},
"unevaluatedProperties": false
}
Example (should not include it):
{
"type": "array",
"items": {
"$ref": "#/components/schemas/EmployeeResponse"
}
}
Actual behavior
unevaluatedProperties: false is emitted for schemas whose type is:
- array
- string
- number
- integer
- boolean
While harmless for validation, this creates unnecessary noise in
generated OpenAPI documents and can confuse downstream consumers.
Why this matters
OpenAPI 3.1 adopts JSON Schema 2020‑12 semantics. In JSON Schema,
unevaluatedProperties applies to object validation, while array
control is handled by unevaluatedItems.
Because of this, emitting unevaluatedProperties on non-object schemas
appears unnecessary and misleading.
Steps to reproduce
Generate an OpenAPI 3.1 document using OpenAPI.NET 3.4 with component
schemas that include arrays or primitive types.
Example generated output:
"Date": {
"unevaluatedProperties": false,
"type": "string",
"format": "date"
}
"EmployeeList": {
"unevaluatedProperties": false,
"type": "array",
"items": {
"$ref": "#/components/schemas/EmployeeResponse"
}
}
Proposed fix
Only emit unevaluatedProperties when:
- the schema type is
object
- or the schema participates in object validation where the keyword is
meaningful
Do not emit it for:
type: array
type: string
type: number
type: integer
type: boolean
type: null
Version info
- OpenAPI.NET: 3.4.0
- OpenAPI document version: 3.1.x
Describe the bug
In OpenAPI.NET 3.4,
unevaluatedProperties: falseis emitted on schemaswhose
typeis notobject, for example arrays and primitive types.Example:
unevaluatedPropertiesis only meaningful for object schemas. Whenemitted on an array, string, number, integer, boolean, or null schema,
it has no effect and appears to be serializer noise.
Expected behavior
unevaluatedPropertiesshould only be serialized when the schema is anobject schema, or otherwise when it can actually apply to object
validation.
Example (valid usage):
{ "type": "object", "properties": { "name": { "type": "string" } }, "unevaluatedProperties": false }Example (should not include it):
{ "type": "array", "items": { "$ref": "#/components/schemas/EmployeeResponse" } }Actual behavior
unevaluatedProperties: falseis emitted for schemas whose type is:While harmless for validation, this creates unnecessary noise in
generated OpenAPI documents and can confuse downstream consumers.
Why this matters
OpenAPI 3.1 adopts JSON Schema 2020‑12 semantics. In JSON Schema,
unevaluatedPropertiesapplies to object validation, while arraycontrol is handled by
unevaluatedItems.Because of this, emitting
unevaluatedPropertieson non-object schemasappears unnecessary and misleading.
Steps to reproduce
Generate an OpenAPI 3.1 document using OpenAPI.NET 3.4 with component
schemas that include arrays or primitive types.
Example generated output:
Proposed fix
Only emit
unevaluatedPropertieswhen:objectmeaningful
Do not emit it for:
type: arraytype: stringtype: numbertype: integertype: booleantype: nullVersion info