Skip to content

Required fields that are not writtable should still be marked as required #3389

@quentinus95

Description

@quentinus95

API Platform version(s) affected: 2.5.5

Description
I'm creating this ticket to give more visibility and context to #3381. Current behavior of API Platform is to ignore the fact that a field is required if it is not writtable.

While this makes sense for write operations, it prevents having strong generated types on clients, as, for instance, a generated ID may be required (in a sense that it is not nullable nor indefinable) but not expected on a POST operation.

I consequently believe that the right way to handle this situation is to handle serialization groups by indicating that the ID should not be POSTed, but is however required (= defined) for GET operations.

How to reproduce
Create an entity with a backend generated ID, inspect OpenAPI generated types, the field is not marked as required as it would be expected.

Possible Solution
See #3381.

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