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..c2730a06fc33 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,37 @@ 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("storage_logs_.gitignore", packagePath + File.separator + srcBasePath + File.separator + "storage" + File.separator + "logs", ".gitignore")); + 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/Authenticate.php b/modules/openapi-generator/src/main/resources/lumen/Authenticate.php index 28b941750199..7cd3d5829a2f 100644 --- a/modules/openapi-generator/src/main/resources/lumen/Authenticate.php +++ b/modules/openapi-generator/src/main/resources/lumen/Authenticate.php @@ -1,6 +1,6 @@ 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,12 @@ | */ -$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'; }); +$app->withFacades(); + 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..cd61e9631634 100644 --- a/modules/openapi-generator/src/main/resources/lumen/readme.md +++ b/modules/openapi-generator/src/main/resources/lumen/readme.md @@ -12,5 +12,11 @@ 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..0f0c9d92f009 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}} @@ -17,9 +17,8 @@ $app->get('/', function () use ($app) { * {{httpMethod}} {{operationId}} * Summary: {{summary}} * 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/modules/openapi-generator/src/main/resources/lumen/storage_logs_.gitignore b/modules/openapi-generator/src/main/resources/lumen/storage_logs_.gitignore new file mode 100644 index 000000000000..c96a04f008ee --- /dev/null +++ b/modules/openapi-generator/src/main/resources/lumen/storage_logs_.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/samples/server/petstore/php-lumen/lib/.env.example b/samples/server/petstore/php-lumen/lib/.env.example new file mode 100644 index 000000000000..9e27ce13c484 --- /dev/null +++ b/samples/server/petstore/php-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/php-lumen/lib/app/Console/Commands/.gitkeep b/samples/server/petstore/php-lumen/lib/app/Console/Commands/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/server/petstore/php-lumen/lib/app/Events/Event.php b/samples/server/petstore/php-lumen/lib/app/Events/Event.php new file mode 100644 index 000000000000..b8230f0fff18 --- /dev/null +++ b/samples/server/petstore/php-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/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..58dc9d942b99 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,12 @@ | */ -$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'; }); +$app->withFacades(); + 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..cd61e9631634 100644 --- a/samples/server/petstore/php-lumen/lib/readme.md +++ b/samples/server/petstore/php-lumen/lib/readme.md @@ -12,5 +12,11 @@ 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/app/Http/routes.php b/samples/server/petstore/php-lumen/lib/routes/web.php similarity index 59% rename from samples/server/petstore/php-lumen/lib/app/Http/routes.php rename to samples/server/petstore/php-lumen/lib/routes/web.php index 2875b96fcb58..21239525ae49 100644 --- a/samples/server/petstore/php-lumen/lib/app/Http/routes.php +++ b/samples/server/petstore/php-lumen/lib/routes/web.php @@ -17,232 +17,200 @@ * @version 1.0.0 */ -$app->get('/', function () use ($app) { - return $app->version(); +$router->get('/', function () use ($router) { + return $router->app->version(); }); /** * patch testSpecialTags * Summary: To test special tags * Notes: To test special tags - * Output-Formats: [application/json] */ -$app->patch('/v2/another-fake/dummy', 'AnotherFakeApi@testSpecialTags'); +$router->patch('/v2/another-fake/dummy', 'AnotherFakeApi@testSpecialTags'); /** * patch testClientModel * Summary: To test \"client\" model * Notes: To test \"client\" model - * Output-Formats: [application/json] */ -$app->patch('/v2/fake', 'FakeApi@testClientModel'); +$router->patch('/v2/fake', 'FakeApi@testClientModel'); /** * post testEndpointParameters * Summary: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * Notes: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - */ -$app->post('/v2/fake', 'FakeApi@testEndpointParameters'); +$router->post('/v2/fake', 'FakeApi@testEndpointParameters'); /** * get testEnumParameters * Summary: To test enum parameters * Notes: To test enum parameters - */ -$app->get('/v2/fake', 'FakeApi@testEnumParameters'); +$router->get('/v2/fake', 'FakeApi@testEnumParameters'); /** * put testBodyWithQueryParams * Summary: * Notes: - */ -$app->put('/v2/fake/body-with-query-params', 'FakeApi@testBodyWithQueryParams'); +$router->put('/v2/fake/body-with-query-params', 'FakeApi@testBodyWithQueryParams'); /** * post testInlineAdditionalProperties * Summary: test inline additionalProperties * Notes: - */ -$app->post('/v2/fake/inline-additionalProperties', 'FakeApi@testInlineAdditionalProperties'); +$router->post('/v2/fake/inline-additionalProperties', 'FakeApi@testInlineAdditionalProperties'); /** * get testJsonFormData * Summary: test json serialization of form data * Notes: - */ -$app->get('/v2/fake/jsonFormData', 'FakeApi@testJsonFormData'); +$router->get('/v2/fake/jsonFormData', 'FakeApi@testJsonFormData'); /** * post fakeOuterBooleanSerialize * Summary: * Notes: Test serialization of outer boolean types - * Output-Formats: [*/*] */ -$app->post('/v2/fake/outer/boolean', 'FakeApi@fakeOuterBooleanSerialize'); +$router->post('/v2/fake/outer/boolean', 'FakeApi@fakeOuterBooleanSerialize'); /** * post fakeOuterCompositeSerialize * Summary: * Notes: Test serialization of object with outer number type - * Output-Formats: [*/*] */ -$app->post('/v2/fake/outer/composite', 'FakeApi@fakeOuterCompositeSerialize'); +$router->post('/v2/fake/outer/composite', 'FakeApi@fakeOuterCompositeSerialize'); /** * post fakeOuterNumberSerialize * Summary: * Notes: Test serialization of outer number types - * Output-Formats: [*/*] */ -$app->post('/v2/fake/outer/number', 'FakeApi@fakeOuterNumberSerialize'); +$router->post('/v2/fake/outer/number', 'FakeApi@fakeOuterNumberSerialize'); /** * post fakeOuterStringSerialize * Summary: * Notes: Test serialization of outer string types - * Output-Formats: [*/*] */ -$app->post('/v2/fake/outer/string', 'FakeApi@fakeOuterStringSerialize'); +$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] */ -$app->patch('/v2/fake_classname_test', 'FakeClassnameTags123Api@testClassname'); +$router->patch('/v2/fake_classname_test', 'FakeClassnameTags123Api@testClassname'); /** * post addPet * Summary: Add a new pet to the store * Notes: - */ -$app->post('/v2/pet', 'PetApi@addPet'); +$router->post('/v2/pet', 'PetApi@addPet'); /** * put updatePet * Summary: Update an existing pet * Notes: - */ -$app->put('/v2/pet', 'PetApi@updatePet'); +$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] */ -$app->get('/v2/pet/findByStatus', 'PetApi@findPetsByStatus'); +$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] */ -$app->get('/v2/pet/findByTags', 'PetApi@findPetsByTags'); +$router->get('/v2/pet/findByTags', 'PetApi@findPetsByTags'); /** * delete deletePet * Summary: Deletes a pet * Notes: - */ -$app->delete('/v2/pet/{petId}', 'PetApi@deletePet'); +$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] */ -$app->get('/v2/pet/{petId}', 'PetApi@getPetById'); +$router->get('/v2/pet/{petId}', 'PetApi@getPetById'); /** * post updatePetWithForm * Summary: Updates a pet in the store with form data * Notes: - */ -$app->post('/v2/pet/{petId}', 'PetApi@updatePetWithForm'); +$router->post('/v2/pet/{petId}', 'PetApi@updatePetWithForm'); /** * post uploadFile * Summary: uploads an image * Notes: - * Output-Formats: [application/json] */ -$app->post('/v2/pet/{petId}/uploadImage', 'PetApi@uploadFile'); +$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] */ -$app->get('/v2/store/inventory', 'StoreApi@getInventory'); +$router->get('/v2/store/inventory', 'StoreApi@getInventory'); /** * post placeOrder * Summary: Place an order for a pet * Notes: - * Output-Formats: [application/xml, application/json] */ -$app->post('/v2/store/order', 'StoreApi@placeOrder'); +$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 - */ -$app->delete('/v2/store/order/{order_id}', 'StoreApi@deleteOrder'); +$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] */ -$app->get('/v2/store/order/{order_id}', 'StoreApi@getOrderById'); +$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. - */ -$app->post('/v2/user', 'UserApi@createUser'); +$router->post('/v2/user', 'UserApi@createUser'); /** * post createUsersWithArrayInput * Summary: Creates list of users with given input array * Notes: - */ -$app->post('/v2/user/createWithArray', 'UserApi@createUsersWithArrayInput'); +$router->post('/v2/user/createWithArray', 'UserApi@createUsersWithArrayInput'); /** * post createUsersWithListInput * Summary: Creates list of users with given input array * Notes: - */ -$app->post('/v2/user/createWithList', 'UserApi@createUsersWithListInput'); +$router->post('/v2/user/createWithList', 'UserApi@createUsersWithListInput'); /** * get loginUser * Summary: Logs user into the system * Notes: - * Output-Formats: [application/xml, application/json] */ -$app->get('/v2/user/login', 'UserApi@loginUser'); +$router->get('/v2/user/login', 'UserApi@loginUser'); /** * get logoutUser * Summary: Logs out current logged in user session * Notes: - */ -$app->get('/v2/user/logout', 'UserApi@logoutUser'); +$router->get('/v2/user/logout', 'UserApi@logoutUser'); /** * delete deleteUser * Summary: Delete user * Notes: This can only be done by the logged in user. - */ -$app->delete('/v2/user/{username}', 'UserApi@deleteUser'); +$router->delete('/v2/user/{username}', 'UserApi@deleteUser'); /** * get getUserByName * Summary: Get user by user name * Notes: - * Output-Formats: [application/xml, application/json] */ -$app->get('/v2/user/{username}', 'UserApi@getUserByName'); +$router->get('/v2/user/{username}', 'UserApi@getUserByName'); /** * put updateUser * Summary: Updated user * Notes: This can only be done by the logged in user. - */ -$app->put('/v2/user/{username}', 'UserApi@updateUser'); +$router->put('/v2/user/{username}', 'UserApi@updateUser'); diff --git a/samples/server/petstore/php-lumen/lib/storage/logs/.gitignore b/samples/server/petstore/php-lumen/lib/storage/logs/.gitignore new file mode 100644 index 000000000000..c96a04f008ee --- /dev/null +++ b/samples/server/petstore/php-lumen/lib/storage/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file 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 @@ +