Skip to content

PATCH schema lost all required properties #7455

@thomas-hiron

Description

@thomas-hiron

API Platform version(s) affected: 4.2.2

Description
Since 4.2.2, my openapi specs changed due to this fix: #6394
There a two issues:

  • the definition name is now postfixed by .jsonMergePath and OpenApi Generator generates new object names. I have to refactor many objects.
  • all my PATCH input definition lost the required properties.

About the required properties, I have PATCH operations on an entity with a different input that has required fields.
Due to this new condition, I understand I won't be able to have a required field in my schema anymore?
How can I get them back?
Should this be a PUT? I'm not sure which is the best here.

How to reproduce

#[ApiResource(
    operations: [
        new Patch(
            uriTemplate: '/my-entities/{uuid}/custom-action',
            input: CustomInput::class,
            processor: CustomInputProcessor::class,
        ),
    ]
)]
#[ORM\Entity]
class MyEntity
{}

class CustomInput
{
    #[Assert\NotBlank]
    public ?string $myProperty = null;
}

Before:

{
    "CustomInput": {
        "type": "object",
        "required": [
            "my_property",
        ],
        "properties": {
            "my_propery": {
                "type": [
                    "string",
                    "null"
                ]
            },
        }
    }
}

After:

{
    "CustomInput.jsonMergePath": {
        "type": "object",
        "properties": {
            "my_propery": {
                "type": [
                    "string",
                    "null"
                ]
            },
        }
    }
}

Possible Solution

Additional Context

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