Skip to content

[Bug]: JMSModelDescriber works badly with customFields #2565

@themark147

Description

@themark147

Version

4.30.0

Description

After upgrade from 4.13.0 -> 4.30.0 ( its happening after that fix: ddeb3d4 ) when i mark some property as NotNull schema is totally different than before update

#[Serializer\Type('enum<Application\SomeStatus>')]
#[Assert\NotNull]
private SomeStatus $status;

4.13.0 (even 4.28.0 is fine) because of error what i provided above
schema:

"properties": {
                    "status": {
                        "$ref": "#/components/schemas/SomeStatus"
                    }
                },
                "type": "object"

after upgrade to 4.29.0+ (in my case 4.30.0 to be exact)

"properties": {
                    "status": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/SomeStatus"
                            }
                        ]
                    }
                },
                "type": "object"

After adding line: unset($customFields['nullable']); to JMSModelDescriber problem was gone and schema was same as it was before update of package

            $customFields = (array) $property->jsonSerialize();
            unset($customFields['property']);
            if ([] === $customFields) { // no custom fields
                $property->ref = $modelRef;
            } else {
                $weakContext = Util::createWeakContext($property->_context);
                $property->oneOf = [new OA\Schema(['ref' => $modelRef, '_context' => $weakContext])];
            }
Image

JSON OpenApi

JSON OpenApi
Replace this text with your JSON (`bin/console nelmio:apidoc:dump`)

Additional context

No response

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