Skip to content

HeaderParameter and validation not coherent #7111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Grummfy opened this issue Apr 23, 2025 · 0 comments
Open

HeaderParameter and validation not coherent #7111

Grummfy opened this issue Apr 23, 2025 · 0 comments

Comments

@Grummfy
Copy link

Grummfy commented Apr 23, 2025

API Platform version(s) affected: 3.4 -> 4.1.x
tested with my project (3.4) and validated that it still exist with master of api-platform/api-platform so I assume 4.x

Description
HeaderParameter constraint seems not coherent. Here, I tested the validation of an header parameter for the api. It seems to be inconsistent.

  • checking that it's required : worked great
  • checking that my value is less or equals than X : work great on the openapi front part, not on back part (no validation)
  • checking that my value is an integer : work great on the openapi front part, not on back part
  • checking that my value is greater or equals than X : failed

How to reproduce

I took the demo project, and on the greeting entity I have make this change

#[ApiResource(mercure: true)]
to
#[ApiResource(mercure: true, parameters: ['Foo' => new HeaderParameter(schema: ['type' => 'integer', 'example' => 3, 'minimum' => 1, 'maximum' => 5], required: true)])]

to check each test, maximum need to be removed to test the other constraint

Possible Solution
validation on the value of the array ?

Additional Context
Perhaps I missuses the HeaderParameter ? But the output in openApi format seems coherent

The constraint is applied on an array (don't know why an array instead of the value), so perhaps it's the reason of the behaviour?

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant