Skip to content

PropertySchemaCollectionRestriction generates invalid OpenAPI schema #5413

Open
@lstrojny

Description

@lstrojny

API Platform version(s) affected: main

Description
When PropertySchemaCollectionRestriction fails to identify nested constraint restrictions the generated OpenAPI schema might be invalid.

How to reproduce
Given this validation rule:

<property name="someArray">
  <constraint name="Collection">
    <option name="fields">
      <value key="someField">
        <constraint name="Optional">
          <constraint name="SomeConstraintWithoutMatchingRestriction"/>
        </constraint>
      </value>
    </option>
  </constraint>
</property>

The generated schema will look like this:

"Schema": {
  "type": "object",
  "properties": {
    "someArray": {
      "type": "object",
      "properties": {
        "someField": [],
      },
      "additionalProperties": false,
      "items": {
        "type": "string"
      }
   }
  }
}

The issue here is that someField is an empty array but should be an empty object.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions