This fixes#15043
The issue is that browsers like "text/html,...,*/*;q=0.8" (see for
instance https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation/List_of_default_Accept_values
)
Without this commit we end up with an array of accepted type like
`("text/html", "*/*;q=0.8)` so when we then check if the array contains
`*/*` the check fails, and we return a 406 even though the client is
able to get the response.
This commit fixes it by removing the `;q=0.8` part.
(Ideally we should not just discard that part, we should extract that
value, and order by it. See
https://developer.mozilla.org/en-US/docs/Glossary/Quality_values for
more info about that. However this could be done in a subsequent PR:
this already fixes the 406 error, which is pretty blocking)
This fixes this Symfony warning:
User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::build()"
might add "void" as a native return type declaration in the future. Do the
same in child class "OpenAPI\Server\OpenAPIServerBundle" now to avoid errors
or add an explicit @return annotation to suppress this message
This fixes#15959
* [PHP-Symfony] fixes validation of date-time parameter
This fixes parts of #14930.
Without this patch a parameter declared as date-time
is validated against Symfony's "DateTime" constraint,
which always fails. Because this constraint expects
a string with format "Y-m-d H:i:s".
It fails because the generated code performs the check
after the deserialization, so the variable checked is not
a string anymore.
Besides this, even if we performed that validation on the
string, that would not work well because OpenApi
specification expects date-time to conform to RFC 3339
and that "Y-m-d H:i:s" would reject RFC 3339 compliant dates.
With this change we ensure that the string provided by the
web user could be parsed by PHP to DateTime, which solves both issues.
(Note however that it means that it now accepts more formats than just
RFC 3339 compliant ones for those parameters (it would accept all formats
accepted by PHP DateTime). That being said it's compliant with the guideline
""be conservative in what you send, be liberal in what you accept")
* [PHP-Symfony] Fix handling of null date-time parameter
This fixes one of the issue described on #14930, namely that
the deserializeString method of the generated class JsmSerializer returns null
for other types of string, but not for date-time. Instead it returns a DateTime
which represents "now" (because that what `new DateTime(null)` does).
Consequently when an API declares a date-time parameter as non-required and
when that endpoint is called without that parameters, then the user code
would end up having "now" instead of "null" for this parameter.
* use .yaml instead of .yml
This is recommended by Symfony standards
* save Bundle files also to src path
* add test for generate ping
* add package imports
* fix expected file names
* why is Api/ApiServer.php missing
* output filenames
* use getAbsolutePath for debug purpose
* do not use punctuation as current directory
* refactor: remove todos
* use also .yaml in test to fix it
* add test for setting a different source directory
* use correct const for setting source dir property in tests
* import the AbstractPhpCodegen in test class
* put also Resources to source path
* save docs not to Resources
* update samples and improve src path in autoload.php and composer.json
* update moved samples
* update parser to 2.0.29
* better handling of null in dereferencing
* update parser to 2.0.30
* update core to newer version
* add new files
* rollback to previous stable version
* remove files
* Fixes for python-experimental NullableShape component
Co-authored-by: Justin Black <justin.a.black@gmail.com>
* add handling of array of oneOfs
* handle res model-type lowercase name +shorten code
* remove unnecessary vendor-extension model enum
* handle openapi lowercase schema name for array res
* change xs:anytype to string for file responses
* update checkstyles
* remove not needed imports again
* update samples
* upper/lowercase use local getdefault
* update samples again