Skip to content

OpenAPI is missing additionalProperties:false (when allow_extra_attributes=false) #4248

@guilliamxavier

Description

@guilliamxavier

API Platform version(s) affected: 2.6.4

Description
(extracted from #4215 (comment))
With default config + denormalizationContext={"allow_extra_attributes": false}, the generated OpenAPI schemas don't have "additionalProperties": false.

How to reproduce
Config:

api_platform:
    defaults:
        denormalization_context:
            allow_extra_attributes: false

and some dummy API resource.
Command (in a Symfony app): php bin/console api:openapi:export

Possible Solution
Remove this line:

            $schema->setDefinitions($schemas);

(introduced by a commit titled "Improve openapi performances").

Additional Context
Even #4247 doesn't fix it.
But if I customize the config by adding this:

    formats:
        jsonld: ['application/ld+json']
    patch_formats:
        json: ['application/merge-patch+json']

then [well, I lose /docs.json and Swagger UI, but I can still run the command, and] the generated schemas do have "additionalProperties": false 🤔

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