-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
New PHP Slim4 Server Generator #3658
Conversation
...penapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java
Outdated
Show resolved
Hide resolved
...penapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java
Outdated
Show resolved
Hide resolved
...penapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java
Show resolved
Hide resolved
...penapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java
Show resolved
Hide resolved
...penapi-generator/src/test/java/org/openapitools/codegen/slim4/PhpSlim4ServerCodegenTest.java
Show resolved
Hide resolved
37f0636
to
9928112
Compare
df56683
to
c8c979c
Compare
I've just finished testing of all endpoints in
Conclusion is that generator is ready to be reviewed and merged. |
I think there are configurable settings to make Apache/Nginx work properly with HTTP headers with underscore in the key name. I don't mind showing a warning/info message reminding users about this default limitations - maybe showing such message starting in the PHP Slim generator that you've been working on. |
65d3e8d
to
c0e214c
Compare
Slim supports PSR-7 interfaces for its Request and Response objects. Slim provides its own PSR-7 implementation so that it works out of the box. However, you are free to replace Slim’s default PSR-7 objects with a third-party implementation. [Ref] https://www.slimframework.com/docs/v4/concepts/value-objects.html
It somehow ended up with composerPackages and composerDevPackages codegen variables and two additional functions. Hope, it's not too much.
Slim’s App settings used to be a part of the container and they have now been decoupled from it. [Upgrade Guide](https://www.slimframework.com/docs/v4/start/upgrade.html)
Slim uses an optional dependency container to prepare, manage, and inject application dependencies. Slim supports containers that implement PSR-11 like [PHP-DI](http://php-di.org/doc/frameworks/slim.html). [Upgrade Guide](https://www.slimframework.com/docs/v4/start/upgrade.html)
You can't write to response instance directly anymore, need to retrieve body object first. [Doc](https://www.slimframework.com/docs/v4/objects/response.html#the-response-body)
User can provide array or Container as constructor argument from now. Small refactoring required to retrieve authentication options from that argument.
This approach seems more flexible to me. User can customize templates in favor of chosen PSR7 implementation. It's easier to change Composer packages and their versions.
Slim4 doesn't parse JSON body, need to add suggested middleware. Ref: https://www.slimframework.com/docs/v4/objects/request.html#the-request-body
Since Slim 4.0.0 ServerRequest implementation doesn't have getQueryParam and getParsedBodyParam methods anymore.
isMultipart codegen property is always false so far. Hope that bug will be fixed soon.
The To generate PHP Slim4 server stub given an OpenAPI/Swagger specification file, please follow 3 simple steps below:
Mac/Linux:
Windows:
|
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.master
,4.1.x
,5.0.x
. Default:master
.Description of the PR
There are breaking changes in Slim 4.0.0 version. In issue #2851 we agreed to add new generator.
I had to update my own Slim Token Authentication fork because original repo author didn't accept my PRs and seems missing.
Upgrade Guide - Slim Framework
Already contains changes from #3621
Closes #2851
cc @jebentier, @dkarlovi, @mandrean, @jfastnacht, @ackintosh, @renepardon
Questions to maintainers
Generator 'php-slim4' is considered stable
seems interesting, where can I change it? This option/flag is not documented as far as I know.bin/security/php-slim-server-petstore.sh
before../bin/openapi3/php-slim-server-petstore.sh
and./bin/php-slim-server-petstore.sh
scripts targets the same./samples/server/petstore/php-slim
directory.