Skip to content

incorrect handling of non-nullable deepObject properties #293

@jharting

Description

@jharting

Consider the following schema:

---
openapi: 3.0.3
info:
  title: Reproducer
  version: 0.0.1

paths:
  /example:
    get:
      operationId: Example
      parameters:
      - in: query
        name: filter
        required: false
        style: deepObject
        explode: true
        schema:
          type: object
          properties:
            foo:
              type: string
            bar:
              type: string
          required: []

      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object

This let's one make a request like
/example?filter[foo]=abc&filter[bar]=def

However, the following request
/example?filter[foo]=abc

fails with
"Parameter 'filter' in query has an error: Error at \"/bar\": Value is not nullable"

This behavior is incorrect as neither of the filter properties is required. Instead of the nullability check, kin-openapi should check whether the property is actually required.

A quick workaround is to add nullable: true to filter's properties. However, that is semantically not correct. The property is not required (i.e. can be omitted) but is not nullable (i.e. it is not valid for it to be explicitly set to a null value).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions