Skip to content

OpenAPI.NET 3.4 emits unevaluatedProperties for non-object schemas #2762

@mdaneri

Description

@mdaneri

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions