diff --git a/bin/php-lumen-petstore-server.sh b/bin/php-lumen-petstore-server.sh
index 2b053fb2124b..586173f89685 100755
--- a/bin/php-lumen-petstore-server.sh
+++ b/bin/php-lumen-petstore-server.sh
@@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate -t modules/openapi-generator/src/main/resources/lumen -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php-lumen -o samples/server/petstore/php-lumen $@"
+ags="generate -t modules/openapi-generator/src/main/resources/lumen -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l php-lumen -o samples/server/petstore/php-lumen $@"
java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/security/lumen-petstore-server.sh b/bin/security/php-lumen-petstore-server.sh
similarity index 93%
rename from bin/security/lumen-petstore-server.sh
rename to bin/security/php-lumen-petstore-server.sh
index f9638aa57097..096e46cfdc9b 100755
--- a/bin/security/lumen-petstore-server.sh
+++ b/bin/security/php-lumen-petstore-server.sh
@@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate -t modules/openapi-generator/src/main/resources/lumen -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-lumen -o samples/server/petstore-security-test/lumen $@"
+ags="generate -t modules/openapi-generator/src/main/resources/lumen -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -l php-lumen -o samples/server/petstore-security-test/lumen $@"
java $JAVA_OPTS -jar $executable $ags
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLumenServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLumenServerCodegen.java
index 2ab003c697d4..e86768c2e933 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLumenServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpLumenServerCodegen.java
@@ -99,18 +99,36 @@ public PhpLumenServerCodegen() {
* entire object tree available. If the input file has a suffix of `.mustache
* it will be processed by the template engine. Otherwise, it will be copied
*/
+ supportingFiles.add(new SupportingFile(".env.example", packagePath + File.separator + srcBasePath, ".env.example"));
+ supportingFiles.add(new SupportingFile("artisan", packagePath + File.separator + srcBasePath, "artisan"));
supportingFiles.add(new SupportingFile("composer.mustache", packagePath + File.separator + srcBasePath, "composer.json"));
supportingFiles.add(new SupportingFile("readme.md", packagePath + File.separator + srcBasePath, "readme.md"));
- supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + srcBasePath + File.separator + "bootstrap", "app.php"));
- supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + srcBasePath + File.separator + "public", "index.php"));
supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + srcBasePath + File.separator + "app", "User.php"));
supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Console", "Kernel.php"));
+ supportingFiles.add(new SupportingFile(".gitkeep", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Console" + File.separator + "Commands", ".gitkeep"));
+ supportingFiles.add(new SupportingFile("Event.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Events", "Event.php"));
+ supportingFiles.add(new SupportingFile("ExampleEvent.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Events", "ExampleEvent.php"));
supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php"));
- supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http", "routes.php"));
-
supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
+ supportingFiles.add(new SupportingFile("ExampleController.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "ExampleController.php"));
supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
-
+ supportingFiles.add(new SupportingFile("ExampleMiddleware.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "ExampleMiddleware.php"));
+ supportingFiles.add(new SupportingFile("ExampleJob.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Jobs", "ExampleJob.php"));
+ supportingFiles.add(new SupportingFile("Job.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Jobs", "Job.php"));
+ supportingFiles.add(new SupportingFile("ExampleListener.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Listeners", "ExampleListener.php"));
+ supportingFiles.add(new SupportingFile("AppServiceProvider.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Providers", "AppServiceProvider.php"));
+ supportingFiles.add(new SupportingFile("AuthServiceProvider.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Providers", "AuthServiceProvider.php"));
+ supportingFiles.add(new SupportingFile("EventServiceProvider.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Providers", "EventServiceProvider.php"));
+ supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + srcBasePath + File.separator + "bootstrap", "app.php"));
+ supportingFiles.add(new SupportingFile("ModelFactory.php", packagePath + File.separator + srcBasePath + File.separator + "database" + File.separator + "factories", "ModelFactory.php"));
+ supportingFiles.add(new SupportingFile(".gitkeep", packagePath + File.separator + srcBasePath + File.separator + "database" + File.separator + "migrations", ".gitkeep"));
+ supportingFiles.add(new SupportingFile("DatabaseSeeder.php", packagePath + File.separator + srcBasePath + File.separator + "database" + File.separator + "seeds", "DatabaseSeeder.php"));
+ supportingFiles.add(new SupportingFile(".htaccess", packagePath + File.separator + srcBasePath + File.separator + "public", ".htaccess"));
+ supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + srcBasePath + File.separator + "public", "index.php"));
+ supportingFiles.add(new SupportingFile(".gitkeep", packagePath + File.separator + srcBasePath + File.separator + "resources" + File.separator + "views", ".gitkeep"));
+ supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + srcBasePath + File.separator + "routes", "web.php"));
+ supportingFiles.add(new SupportingFile("ExampleTest.php", packagePath + File.separator + srcBasePath + File.separator + "tests", "ExampleTest.php"));
+ supportingFiles.add(new SupportingFile("TestCase.php", packagePath + File.separator + srcBasePath + File.separator + "tests", "TestCase.php"));
}
// override with any special post-processing
diff --git a/modules/openapi-generator/src/main/resources/lumen/.env.example b/modules/openapi-generator/src/main/resources/lumen/.env.example
new file mode 100644
index 000000000000..9e27ce13c484
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/lumen/.env.example
@@ -0,0 +1,17 @@
+APP_ENV=local
+APP_DEBUG=true
+APP_KEY=
+APP_TIMEZONE=UTC
+
+LOG_CHANNEL=stack
+LOG_SLACK_WEBHOOK_URL=
+
+DB_CONNECTION=mysql
+DB_HOST=127.0.0.1
+DB_PORT=3306
+DB_DATABASE=homestead
+DB_USERNAME=homestead
+DB_PASSWORD=secret
+
+CACHE_DRIVER=file
+QUEUE_DRIVER=sync
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/lumen/.gitkeep b/modules/openapi-generator/src/main/resources/lumen/.gitkeep
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/modules/openapi-generator/src/main/resources/lumen/.htaccess b/modules/openapi-generator/src/main/resources/lumen/.htaccess
new file mode 100644
index 000000000000..b75525bedcd8
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/lumen/.htaccess
@@ -0,0 +1,21 @@
+
+
+ Options -MultiViews -Indexes
+
+
+ RewriteEngine On
+
+ # Handle Authorization Header
+ RewriteCond %{HTTP:Authorization} .
+ RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+
+ # Redirect Trailing Slashes If Not A Folder...
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_URI} (.+)/$
+ RewriteRule ^ %1 [L,R=301]
+
+ # Handle Front Controller...
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^ index.php [L]
+
diff --git a/modules/openapi-generator/src/main/resources/lumen/AppServiceProvider.php b/modules/openapi-generator/src/main/resources/lumen/AppServiceProvider.php
new file mode 100644
index 000000000000..ddec04694c37
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/lumen/AppServiceProvider.php
@@ -0,0 +1,18 @@
+app['auth']->viaRequest('api', function ($request) {
+ if ($request->input('api_token')) {
+ return User::where('api_token', $request->input('api_token'))->first();
+ }
+ });
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/lumen/DatabaseSeeder.php b/modules/openapi-generator/src/main/resources/lumen/DatabaseSeeder.php
new file mode 100644
index 000000000000..23526c9d99ce
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/lumen/DatabaseSeeder.php
@@ -0,0 +1,16 @@
+call('UsersTableSeeder');
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/lumen/Event.php b/modules/openapi-generator/src/main/resources/lumen/Event.php
new file mode 100644
index 000000000000..b8230f0fff18
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/lumen/Event.php
@@ -0,0 +1,10 @@
+ [
+ 'App\Listeners\ExampleListener',
+ ],
+ ];
+}
diff --git a/modules/openapi-generator/src/main/resources/lumen/ExampleController.php b/modules/openapi-generator/src/main/resources/lumen/ExampleController.php
new file mode 100644
index 000000000000..aab066e8c7d7
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/lumen/ExampleController.php
@@ -0,0 +1,18 @@
+get('/');
+
+ $this->assertEquals(
+ $this->app->version(), $this->response->getContent()
+ );
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/lumen/Job.php b/modules/openapi-generator/src/main/resources/lumen/Job.php
new file mode 100644
index 000000000000..7c873e10bdfb
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/lumen/Job.php
@@ -0,0 +1,24 @@
+define(App\User::class, function (Faker\Generator $faker) {
+ return [
+ 'name' => $faker->name,
+ 'email' => $faker->email,
+ ];
+});
diff --git a/modules/openapi-generator/src/main/resources/lumen/TestCase.php b/modules/openapi-generator/src/main/resources/lumen/TestCase.php
new file mode 100644
index 000000000000..89a058d12105
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/lumen/TestCase.php
@@ -0,0 +1,14 @@
+withFacades();
+// $app->withFacades();
// $app->withEloquent();
@@ -99,8 +99,10 @@
|
*/
-$app->group(['namespace' => 'App\Http\Controllers'], function ($app) {
- require __DIR__.'/../app/Http/routes.php';
+$app->router->group([
+ 'namespace' => 'App\Http\Controllers',
+], function ($router) {
+ require __DIR__.'/../routes/web.php';
});
return $app;
diff --git a/modules/openapi-generator/src/main/resources/lumen/composer.mustache b/modules/openapi-generator/src/main/resources/lumen/composer.mustache
index f4a6f740f0bb..e1fb93758aea 100644
--- a/modules/openapi-generator/src/main/resources/lumen/composer.mustache
+++ b/modules/openapi-generator/src/main/resources/lumen/composer.mustache
@@ -5,6 +5,9 @@
{{/artifactVersion}}
"description": "{{description}}",
"keywords": [
+ "framework",
+ "laravel",
+ "lumen",
"openapi",
"openapitools",
"php",
@@ -19,14 +22,38 @@
"homepage": "https://openapi-generator.tech"
}
],
+ "type": "project",
"require": {
- "php": ">=5.5.9",
- "laravel/lumen-framework": "5.2.*",
+ "php": ">=7.1.3",
+ "laravel/lumen-framework": "5.6.*",
"vlucas/phpdotenv": "~2.2"
},
+ "require-dev": {
+ "fzaninotto/faker": "~1.4",
+ "phpunit/phpunit": "~7.0",
+ "mockery/mockery": "~1.0"
+ },
"autoload": {
"psr-4": {
"App\\": "app/"
}
- }
+ },
+ "autoload-dev": {
+ "classmap": [
+ "tests/",
+ "database/"
+ ]
+ },
+ "scripts": {
+ "post-root-package-install": [
+ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
+ ]
+ },
+ "config": {
+ "preferred-install": "dist",
+ "sort-packages": true,
+ "optimize-autoloader": true
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true
}
diff --git a/modules/openapi-generator/src/main/resources/lumen/phpunit.xml b/modules/openapi-generator/src/main/resources/lumen/phpunit.xml
new file mode 100644
index 000000000000..c703297e25a5
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/lumen/phpunit.xml
@@ -0,0 +1,27 @@
+
+
+
+
+ ./tests
+
+
+
+
+ ./app
+
+
+
+
+
+
+
+
diff --git a/modules/openapi-generator/src/main/resources/lumen/readme.md b/modules/openapi-generator/src/main/resources/lumen/readme.md
index b57e2fc40ba9..3a18063fb0ea 100644
--- a/modules/openapi-generator/src/main/resources/lumen/readme.md
+++ b/modules/openapi-generator/src/main/resources/lumen/readme.md
@@ -12,5 +12,10 @@ This example uses the [Lumen Framework](http://lumen.laravel.com/). To see how
## Installation & Usage
### Composer
-Using `composer install` to install the framework and dependencies via [Composer](http://getcomposer.org/).
+Switch to the generated Lumen server stub directory.
+Using `composer update` to install the framework and dependencies via [Composer](http://getcomposer.org/).
+## Note
+
+The `composer update` should be the first thing to do right after generating Lumen server stub. The autoload.php will be generated only after excuting `composer update`.
+Or there would be errors during service or model migration.
diff --git a/modules/openapi-generator/src/main/resources/lumen/routes.mustache b/modules/openapi-generator/src/main/resources/lumen/routes.mustache
index c5d4f10d4b70..0da1633f1413 100644
--- a/modules/openapi-generator/src/main/resources/lumen/routes.mustache
+++ b/modules/openapi-generator/src/main/resources/lumen/routes.mustache
@@ -6,8 +6,8 @@
* @version {{appVersion}}
*/
-$app->get('/', function () use ($app) {
- return $app->version();
+$router->get('/', function () use ($router) {
+ return $router->app->version();
});
{{#apis}}
@@ -19,7 +19,7 @@ $app->get('/', function () use ($app) {
* Notes: {{notes}}
{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
*/
-$app->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', '{{classname}}@{{operationId}}');
+$router->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', '{{classname}}@{{operationId}}');
{{/operation}}
{{/operations}}
{{/apis}}
diff --git a/samples/server/petstore-security-test/lumen/lib/.env.example b/samples/server/petstore-security-test/lumen/lib/.env.example
new file mode 100644
index 000000000000..9e27ce13c484
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/.env.example
@@ -0,0 +1,17 @@
+APP_ENV=local
+APP_DEBUG=true
+APP_KEY=
+APP_TIMEZONE=UTC
+
+LOG_CHANNEL=stack
+LOG_SLACK_WEBHOOK_URL=
+
+DB_CONNECTION=mysql
+DB_HOST=127.0.0.1
+DB_PORT=3306
+DB_DATABASE=homestead
+DB_USERNAME=homestead
+DB_PASSWORD=secret
+
+CACHE_DRIVER=file
+QUEUE_DRIVER=sync
\ No newline at end of file
diff --git a/samples/server/petstore-security-test/lumen/lib/app/Console/Commands/.gitkeep b/samples/server/petstore-security-test/lumen/lib/app/Console/Commands/.gitkeep
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/samples/server/petstore-security-test/lumen/lib/app/Events/Event.php b/samples/server/petstore-security-test/lumen/lib/app/Events/Event.php
new file mode 100644
index 000000000000..b8230f0fff18
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/app/Events/Event.php
@@ -0,0 +1,10 @@
+app['auth']->viaRequest('api', function ($request) {
+ if ($request->input('api_token')) {
+ return User::where('api_token', $request->input('api_token'))->first();
+ }
+ });
+ }
+}
diff --git a/samples/server/petstore-security-test/lumen/lib/app/Providers/EventServiceProvider.php b/samples/server/petstore-security-test/lumen/lib/app/Providers/EventServiceProvider.php
new file mode 100644
index 000000000000..a3d284fc29fb
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/app/Providers/EventServiceProvider.php
@@ -0,0 +1,19 @@
+ [
+ 'App\Listeners\ExampleListener',
+ ],
+ ];
+}
diff --git a/samples/server/petstore-security-test/lumen/lib/artisan b/samples/server/petstore-security-test/lumen/lib/artisan
new file mode 100644
index 000000000000..6a9d095aeae0
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/artisan
@@ -0,0 +1,35 @@
+#!/usr/bin/env php
+make(
+ 'Illuminate\Contracts\Console\Kernel'
+);
+
+exit($kernel->handle(new ArgvInput, new ConsoleOutput));
diff --git a/samples/server/petstore-security-test/lumen/lib/bootstrap/app.php b/samples/server/petstore-security-test/lumen/lib/bootstrap/app.php
index d80e7f644e6d..3d1185059c3a 100644
--- a/samples/server/petstore-security-test/lumen/lib/bootstrap/app.php
+++ b/samples/server/petstore-security-test/lumen/lib/bootstrap/app.php
@@ -29,7 +29,7 @@
realpath(__DIR__.'/../')
);
-$app->withFacades();
+// $app->withFacades();
// $app->withEloquent();
@@ -99,8 +99,10 @@
|
*/
-$app->group(['namespace' => 'App\Http\Controllers'], function ($app) {
- require __DIR__.'/../app/Http/routes.php';
+$app->router->group([
+ 'namespace' => 'App\Http\Controllers',
+], function ($router) {
+ require __DIR__.'/../routes/web.php';
});
return $app;
diff --git a/samples/server/petstore-security-test/lumen/lib/composer.json b/samples/server/petstore-security-test/lumen/lib/composer.json
index 650a432f78db..56f9720b5341 100644
--- a/samples/server/petstore-security-test/lumen/lib/composer.json
+++ b/samples/server/petstore-security-test/lumen/lib/composer.json
@@ -2,6 +2,9 @@
"name": "GIT_USER_ID/GIT_REPO_ID",
"description": "",
"keywords": [
+ "framework",
+ "laravel",
+ "lumen",
"openapi",
"openapitools",
"php",
@@ -16,14 +19,38 @@
"homepage": "https://openapi-generator.tech"
}
],
+ "type": "project",
"require": {
- "php": ">=5.5.9",
- "laravel/lumen-framework": "5.2.*",
+ "php": ">=7.1.3",
+ "laravel/lumen-framework": "5.6.*",
"vlucas/phpdotenv": "~2.2"
},
+ "require-dev": {
+ "fzaninotto/faker": "~1.4",
+ "phpunit/phpunit": "~7.0",
+ "mockery/mockery": "~1.0"
+ },
"autoload": {
"psr-4": {
"App\\": "app/"
}
- }
+ },
+ "autoload-dev": {
+ "classmap": [
+ "tests/",
+ "database/"
+ ]
+ },
+ "scripts": {
+ "post-root-package-install": [
+ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
+ ]
+ },
+ "config": {
+ "preferred-install": "dist",
+ "sort-packages": true,
+ "optimize-autoloader": true
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true
}
diff --git a/samples/server/petstore-security-test/lumen/lib/database/factories/ModelFactory.php b/samples/server/petstore-security-test/lumen/lib/database/factories/ModelFactory.php
new file mode 100644
index 000000000000..bf9496b0eef4
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/database/factories/ModelFactory.php
@@ -0,0 +1,19 @@
+define(App\User::class, function (Faker\Generator $faker) {
+ return [
+ 'name' => $faker->name,
+ 'email' => $faker->email,
+ ];
+});
diff --git a/samples/server/petstore-security-test/lumen/lib/database/migrations/.gitkeep b/samples/server/petstore-security-test/lumen/lib/database/migrations/.gitkeep
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/samples/server/petstore-security-test/lumen/lib/database/seeds/DatabaseSeeder.php b/samples/server/petstore-security-test/lumen/lib/database/seeds/DatabaseSeeder.php
new file mode 100644
index 000000000000..23526c9d99ce
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/database/seeds/DatabaseSeeder.php
@@ -0,0 +1,16 @@
+call('UsersTableSeeder');
+ }
+}
diff --git a/samples/server/petstore-security-test/lumen/lib/public/.htaccess b/samples/server/petstore-security-test/lumen/lib/public/.htaccess
new file mode 100644
index 000000000000..b75525bedcd8
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/public/.htaccess
@@ -0,0 +1,21 @@
+
+
+ Options -MultiViews -Indexes
+
+
+ RewriteEngine On
+
+ # Handle Authorization Header
+ RewriteCond %{HTTP:Authorization} .
+ RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+
+ # Redirect Trailing Slashes If Not A Folder...
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_URI} (.+)/$
+ RewriteRule ^ %1 [L,R=301]
+
+ # Handle Front Controller...
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^ index.php [L]
+
diff --git a/samples/server/petstore-security-test/lumen/lib/readme.md b/samples/server/petstore-security-test/lumen/lib/readme.md
index b57e2fc40ba9..3a18063fb0ea 100644
--- a/samples/server/petstore-security-test/lumen/lib/readme.md
+++ b/samples/server/petstore-security-test/lumen/lib/readme.md
@@ -12,5 +12,10 @@ This example uses the [Lumen Framework](http://lumen.laravel.com/). To see how
## Installation & Usage
### Composer
-Using `composer install` to install the framework and dependencies via [Composer](http://getcomposer.org/).
+Switch to the generated Lumen server stub directory.
+Using `composer update` to install the framework and dependencies via [Composer](http://getcomposer.org/).
+## Note
+
+The `composer update` should be the first thing to do right after generating Lumen server stub. The autoload.php will be generated only after excuting `composer update`.
+Or there would be errors during service or model migration.
diff --git a/samples/server/petstore-security-test/lumen/lib/resources/views/.gitkeep b/samples/server/petstore-security-test/lumen/lib/resources/views/.gitkeep
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/samples/server/petstore-security-test/lumen/lib/routes/web.php b/samples/server/petstore-security-test/lumen/lib/routes/web.php
new file mode 100644
index 000000000000..bc6e0de797c4
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/routes/web.php
@@ -0,0 +1,31 @@
+get('/', function () use ($router) {
+ return $router->app->version();
+});
+
+/**
+ * put testCodeInjectEndRnNR
+ * Summary: To test code injection ' \" =end -- \\r\\n \\n \\r
+ * Notes:
+
+ */
+$router->put('/fake', 'FakeApi@testCodeInjectEndRnNR');
+
diff --git a/samples/server/petstore-security-test/lumen/lib/tests/ExampleTest.php b/samples/server/petstore-security-test/lumen/lib/tests/ExampleTest.php
new file mode 100644
index 000000000000..1bad6ef7ed7d
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/tests/ExampleTest.php
@@ -0,0 +1,21 @@
+get('/');
+
+ $this->assertEquals(
+ $this->app->version(), $this->response->getContent()
+ );
+ }
+}
diff --git a/samples/server/petstore-security-test/lumen/lib/tests/TestCase.php b/samples/server/petstore-security-test/lumen/lib/tests/TestCase.php
new file mode 100644
index 000000000000..89a058d12105
--- /dev/null
+++ b/samples/server/petstore-security-test/lumen/lib/tests/TestCase.php
@@ -0,0 +1,14 @@
+app['auth']->viaRequest('api', function ($request) {
+ if ($request->input('api_token')) {
+ return User::where('api_token', $request->input('api_token'))->first();
+ }
+ });
+ }
+}
diff --git a/samples/server/petstore/php-lumen/lib/app/Providers/EventServiceProvider.php b/samples/server/petstore/php-lumen/lib/app/Providers/EventServiceProvider.php
new file mode 100644
index 000000000000..a3d284fc29fb
--- /dev/null
+++ b/samples/server/petstore/php-lumen/lib/app/Providers/EventServiceProvider.php
@@ -0,0 +1,19 @@
+ [
+ 'App\Listeners\ExampleListener',
+ ],
+ ];
+}
diff --git a/samples/server/petstore/php-lumen/lib/artisan b/samples/server/petstore/php-lumen/lib/artisan
new file mode 100644
index 000000000000..6a9d095aeae0
--- /dev/null
+++ b/samples/server/petstore/php-lumen/lib/artisan
@@ -0,0 +1,35 @@
+#!/usr/bin/env php
+make(
+ 'Illuminate\Contracts\Console\Kernel'
+);
+
+exit($kernel->handle(new ArgvInput, new ConsoleOutput));
diff --git a/samples/server/petstore/php-lumen/lib/bootstrap/app.php b/samples/server/petstore/php-lumen/lib/bootstrap/app.php
index d80e7f644e6d..3d1185059c3a 100644
--- a/samples/server/petstore/php-lumen/lib/bootstrap/app.php
+++ b/samples/server/petstore/php-lumen/lib/bootstrap/app.php
@@ -29,7 +29,7 @@
realpath(__DIR__.'/../')
);
-$app->withFacades();
+// $app->withFacades();
// $app->withEloquent();
@@ -99,8 +99,10 @@
|
*/
-$app->group(['namespace' => 'App\Http\Controllers'], function ($app) {
- require __DIR__.'/../app/Http/routes.php';
+$app->router->group([
+ 'namespace' => 'App\Http\Controllers',
+], function ($router) {
+ require __DIR__.'/../routes/web.php';
});
return $app;
diff --git a/samples/server/petstore/php-lumen/lib/composer.json b/samples/server/petstore/php-lumen/lib/composer.json
index 650a432f78db..56f9720b5341 100644
--- a/samples/server/petstore/php-lumen/lib/composer.json
+++ b/samples/server/petstore/php-lumen/lib/composer.json
@@ -2,6 +2,9 @@
"name": "GIT_USER_ID/GIT_REPO_ID",
"description": "",
"keywords": [
+ "framework",
+ "laravel",
+ "lumen",
"openapi",
"openapitools",
"php",
@@ -16,14 +19,38 @@
"homepage": "https://openapi-generator.tech"
}
],
+ "type": "project",
"require": {
- "php": ">=5.5.9",
- "laravel/lumen-framework": "5.2.*",
+ "php": ">=7.1.3",
+ "laravel/lumen-framework": "5.6.*",
"vlucas/phpdotenv": "~2.2"
},
+ "require-dev": {
+ "fzaninotto/faker": "~1.4",
+ "phpunit/phpunit": "~7.0",
+ "mockery/mockery": "~1.0"
+ },
"autoload": {
"psr-4": {
"App\\": "app/"
}
- }
+ },
+ "autoload-dev": {
+ "classmap": [
+ "tests/",
+ "database/"
+ ]
+ },
+ "scripts": {
+ "post-root-package-install": [
+ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
+ ]
+ },
+ "config": {
+ "preferred-install": "dist",
+ "sort-packages": true,
+ "optimize-autoloader": true
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true
}
diff --git a/samples/server/petstore/php-lumen/lib/database/factories/ModelFactory.php b/samples/server/petstore/php-lumen/lib/database/factories/ModelFactory.php
new file mode 100644
index 000000000000..bf9496b0eef4
--- /dev/null
+++ b/samples/server/petstore/php-lumen/lib/database/factories/ModelFactory.php
@@ -0,0 +1,19 @@
+define(App\User::class, function (Faker\Generator $faker) {
+ return [
+ 'name' => $faker->name,
+ 'email' => $faker->email,
+ ];
+});
diff --git a/samples/server/petstore/php-lumen/lib/database/migrations/.gitkeep b/samples/server/petstore/php-lumen/lib/database/migrations/.gitkeep
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/samples/server/petstore/php-lumen/lib/database/seeds/DatabaseSeeder.php b/samples/server/petstore/php-lumen/lib/database/seeds/DatabaseSeeder.php
new file mode 100644
index 000000000000..23526c9d99ce
--- /dev/null
+++ b/samples/server/petstore/php-lumen/lib/database/seeds/DatabaseSeeder.php
@@ -0,0 +1,16 @@
+call('UsersTableSeeder');
+ }
+}
diff --git a/samples/server/petstore/php-lumen/lib/public/.htaccess b/samples/server/petstore/php-lumen/lib/public/.htaccess
new file mode 100644
index 000000000000..b75525bedcd8
--- /dev/null
+++ b/samples/server/petstore/php-lumen/lib/public/.htaccess
@@ -0,0 +1,21 @@
+
+
+ Options -MultiViews -Indexes
+
+
+ RewriteEngine On
+
+ # Handle Authorization Header
+ RewriteCond %{HTTP:Authorization} .
+ RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+
+ # Redirect Trailing Slashes If Not A Folder...
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_URI} (.+)/$
+ RewriteRule ^ %1 [L,R=301]
+
+ # Handle Front Controller...
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^ index.php [L]
+
diff --git a/samples/server/petstore/php-lumen/lib/readme.md b/samples/server/petstore/php-lumen/lib/readme.md
index b57e2fc40ba9..3a18063fb0ea 100644
--- a/samples/server/petstore/php-lumen/lib/readme.md
+++ b/samples/server/petstore/php-lumen/lib/readme.md
@@ -12,5 +12,10 @@ This example uses the [Lumen Framework](http://lumen.laravel.com/). To see how
## Installation & Usage
### Composer
-Using `composer install` to install the framework and dependencies via [Composer](http://getcomposer.org/).
+Switch to the generated Lumen server stub directory.
+Using `composer update` to install the framework and dependencies via [Composer](http://getcomposer.org/).
+## Note
+
+The `composer update` should be the first thing to do right after generating Lumen server stub. The autoload.php will be generated only after excuting `composer update`.
+Or there would be errors during service or model migration.
diff --git a/samples/server/petstore/php-lumen/lib/resources/views/.gitkeep b/samples/server/petstore/php-lumen/lib/resources/views/.gitkeep
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/samples/server/petstore/php-lumen/lib/routes/web.php b/samples/server/petstore/php-lumen/lib/routes/web.php
new file mode 100644
index 000000000000..5686f4e3ed50
--- /dev/null
+++ b/samples/server/petstore/php-lumen/lib/routes/web.php
@@ -0,0 +1,248 @@
+get('/', function () use ($router) {
+ return $router->app->version();
+});
+
+/**
+ * patch testSpecialTags
+ * Summary: To test special tags
+ * Notes: To test special tags
+ * Output-Formats: [application/json]
+ */
+$router->patch('/v2/another-fake/dummy', 'AnotherFakeApi@testSpecialTags');
+/**
+ * patch testClientModel
+ * Summary: To test \"client\" model
+ * Notes: To test \"client\" model
+ * Output-Formats: [application/json]
+ */
+$router->patch('/v2/fake', 'FakeApi@testClientModel');
+/**
+ * post testEndpointParameters
+ * Summary: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
+ * Notes: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
+
+ */
+$router->post('/v2/fake', 'FakeApi@testEndpointParameters');
+/**
+ * get testEnumParameters
+ * Summary: To test enum parameters
+ * Notes: To test enum parameters
+
+ */
+$router->get('/v2/fake', 'FakeApi@testEnumParameters');
+/**
+ * put testBodyWithQueryParams
+ * Summary:
+ * Notes:
+
+ */
+$router->put('/v2/fake/body-with-query-params', 'FakeApi@testBodyWithQueryParams');
+/**
+ * post testInlineAdditionalProperties
+ * Summary: test inline additionalProperties
+ * Notes:
+
+ */
+$router->post('/v2/fake/inline-additionalProperties', 'FakeApi@testInlineAdditionalProperties');
+/**
+ * get testJsonFormData
+ * Summary: test json serialization of form data
+ * Notes:
+
+ */
+$router->get('/v2/fake/jsonFormData', 'FakeApi@testJsonFormData');
+/**
+ * post fakeOuterBooleanSerialize
+ * Summary:
+ * Notes: Test serialization of outer boolean types
+ * Output-Formats: [*/*]
+ */
+$router->post('/v2/fake/outer/boolean', 'FakeApi@fakeOuterBooleanSerialize');
+/**
+ * post fakeOuterCompositeSerialize
+ * Summary:
+ * Notes: Test serialization of object with outer number type
+ * Output-Formats: [*/*]
+ */
+$router->post('/v2/fake/outer/composite', 'FakeApi@fakeOuterCompositeSerialize');
+/**
+ * post fakeOuterNumberSerialize
+ * Summary:
+ * Notes: Test serialization of outer number types
+ * Output-Formats: [*/*]
+ */
+$router->post('/v2/fake/outer/number', 'FakeApi@fakeOuterNumberSerialize');
+/**
+ * post fakeOuterStringSerialize
+ * Summary:
+ * Notes: Test serialization of outer string types
+ * Output-Formats: [*/*]
+ */
+$router->post('/v2/fake/outer/string', 'FakeApi@fakeOuterStringSerialize');
+/**
+ * patch testClassname
+ * Summary: To test class name in snake case
+ * Notes: To test class name in snake case
+ * Output-Formats: [application/json]
+ */
+$router->patch('/v2/fake_classname_test', 'FakeClassnameTags123Api@testClassname');
+/**
+ * post addPet
+ * Summary: Add a new pet to the store
+ * Notes:
+
+ */
+$router->post('/v2/pet', 'PetApi@addPet');
+/**
+ * put updatePet
+ * Summary: Update an existing pet
+ * Notes:
+
+ */
+$router->put('/v2/pet', 'PetApi@updatePet');
+/**
+ * get findPetsByStatus
+ * Summary: Finds Pets by status
+ * Notes: Multiple status values can be provided with comma separated strings
+ * Output-Formats: [application/xml, application/json]
+ */
+$router->get('/v2/pet/findByStatus', 'PetApi@findPetsByStatus');
+/**
+ * get findPetsByTags
+ * Summary: Finds Pets by tags
+ * Notes: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+ * Output-Formats: [application/xml, application/json]
+ */
+$router->get('/v2/pet/findByTags', 'PetApi@findPetsByTags');
+/**
+ * delete deletePet
+ * Summary: Deletes a pet
+ * Notes:
+
+ */
+$router->delete('/v2/pet/{petId}', 'PetApi@deletePet');
+/**
+ * get getPetById
+ * Summary: Find pet by ID
+ * Notes: Returns a single pet
+ * Output-Formats: [application/xml, application/json]
+ */
+$router->get('/v2/pet/{petId}', 'PetApi@getPetById');
+/**
+ * post updatePetWithForm
+ * Summary: Updates a pet in the store with form data
+ * Notes:
+
+ */
+$router->post('/v2/pet/{petId}', 'PetApi@updatePetWithForm');
+/**
+ * post uploadFile
+ * Summary: uploads an image
+ * Notes:
+ * Output-Formats: [application/json]
+ */
+$router->post('/v2/pet/{petId}/uploadImage', 'PetApi@uploadFile');
+/**
+ * get getInventory
+ * Summary: Returns pet inventories by status
+ * Notes: Returns a map of status codes to quantities
+ * Output-Formats: [application/json]
+ */
+$router->get('/v2/store/inventory', 'StoreApi@getInventory');
+/**
+ * post placeOrder
+ * Summary: Place an order for a pet
+ * Notes:
+ * Output-Formats: [application/xml, application/json]
+ */
+$router->post('/v2/store/order', 'StoreApi@placeOrder');
+/**
+ * delete deleteOrder
+ * Summary: Delete purchase order by ID
+ * Notes: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+
+ */
+$router->delete('/v2/store/order/{order_id}', 'StoreApi@deleteOrder');
+/**
+ * get getOrderById
+ * Summary: Find purchase order by ID
+ * Notes: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ * Output-Formats: [application/xml, application/json]
+ */
+$router->get('/v2/store/order/{order_id}', 'StoreApi@getOrderById');
+/**
+ * post createUser
+ * Summary: Create user
+ * Notes: This can only be done by the logged in user.
+
+ */
+$router->post('/v2/user', 'UserApi@createUser');
+/**
+ * post createUsersWithArrayInput
+ * Summary: Creates list of users with given input array
+ * Notes:
+
+ */
+$router->post('/v2/user/createWithArray', 'UserApi@createUsersWithArrayInput');
+/**
+ * post createUsersWithListInput
+ * Summary: Creates list of users with given input array
+ * Notes:
+
+ */
+$router->post('/v2/user/createWithList', 'UserApi@createUsersWithListInput');
+/**
+ * get loginUser
+ * Summary: Logs user into the system
+ * Notes:
+ * Output-Formats: [application/xml, application/json]
+ */
+$router->get('/v2/user/login', 'UserApi@loginUser');
+/**
+ * get logoutUser
+ * Summary: Logs out current logged in user session
+ * Notes:
+
+ */
+$router->get('/v2/user/logout', 'UserApi@logoutUser');
+/**
+ * delete deleteUser
+ * Summary: Delete user
+ * Notes: This can only be done by the logged in user.
+
+ */
+$router->delete('/v2/user/{username}', 'UserApi@deleteUser');
+/**
+ * get getUserByName
+ * Summary: Get user by user name
+ * Notes:
+ * Output-Formats: [application/xml, application/json]
+ */
+$router->get('/v2/user/{username}', 'UserApi@getUserByName');
+/**
+ * put updateUser
+ * Summary: Updated user
+ * Notes: This can only be done by the logged in user.
+
+ */
+$router->put('/v2/user/{username}', 'UserApi@updateUser');
+
diff --git a/samples/server/petstore/php-lumen/lib/tests/ExampleTest.php b/samples/server/petstore/php-lumen/lib/tests/ExampleTest.php
new file mode 100644
index 000000000000..1bad6ef7ed7d
--- /dev/null
+++ b/samples/server/petstore/php-lumen/lib/tests/ExampleTest.php
@@ -0,0 +1,21 @@
+get('/');
+
+ $this->assertEquals(
+ $this->app->version(), $this->response->getContent()
+ );
+ }
+}
diff --git a/samples/server/petstore/php-lumen/lib/tests/TestCase.php b/samples/server/petstore/php-lumen/lib/tests/TestCase.php
new file mode 100644
index 000000000000..89a058d12105
--- /dev/null
+++ b/samples/server/petstore/php-lumen/lib/tests/TestCase.php
@@ -0,0 +1,14 @@
+