Skip to content
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

[BUG][PHP][Symfony] Warning OpenAPIServerBundle::build() should explicitely say it returns void #15959

Closed
5 of 6 tasks
gturri opened this issue Jun 30, 2023 · 0 comments
Closed
5 of 6 tasks

Comments

@gturri
Copy link
Contributor

gturri commented Jun 30, 2023

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When I use a Symfony bundle generated by openApiGenerator, Symfony display this warning:

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

openapi-generator version

I've observed this behavior with openapi-generator 6.6.0. I've also reproduced it with a version built from source with today's master branch (d5c53b9)

OpenAPI declaration file content or url

It can be observed with any OpenAPI file. Let's take for instance this simple one:

openapi: 3.0.1
info:
  title: Test
  version: 0.0.1
paths:
  /my-route:
    get:
      summary: Get stuff
      responses:
        "200":
          description: OK
Generation Details
java -jar openapi.jar generate --git-user-id "userid" --git-repo-id "repoid" -i "openapi.yaml" -g php-symfony -o "out"
Steps to reproduce

Plus the generated Symfony bundle into a Symfony app (following the steps in the auto-generated README). Then launch the Symfony server (symfony server:start --no-tls) and perform a query against this route curl http://localhost:8000/my-route

Expected behavior: Symfony handle this query without outputting warning because of the generated code.
Actual behavior: Symfony output this warning (on the server stdout):
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

(nb: there is another similar warning, related to a method in the jms/serializer-bundle package. I'm leaving it out of the scope of this bug report because I think it would deserve its own bug report (because the fix would not really be the same since that other warning would rather imply a bump of that jms package))

Related issues/PRs

I searched for related issues and PRs, but did not found any.

Suggest a fix

The fix is easy: we just need to declare a void return type for that method, by editing modules/openapi-generator/src/main/resources/php-symfony/Bundle.mustache . This is fixed by PR #15960

gturri added a commit to gturri/openapi-generator that referenced this issue Jun 30, 2023
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 OpenAPITools#15959
@wing328 wing328 closed this as completed in 7572e73 Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant