diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java index fbd98c034df..abc747435bf 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java @@ -9,9 +9,20 @@ import java.io.File; public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig { // source folder where to write the files - protected String sourceFolder = "src"; - protected String apiVersion = "1.0.0"; + protected String sourceFolder = ""; + public static final String SRC_BASE_PATH = "srcBasePath"; + public static final String COMPOSER_VENDOR_NAME = "composerVendorName"; + public static final String COMPOSER_PROJECT_NAME = "composerProjectName"; + protected String invokerPackage = "Swagger\\Client"; + protected String composerVendorName = null; + protected String composerProjectName = null; + protected String packagePath = "SwaggerClient-php"; + protected String artifactVersion = null; + protected String srcBasePath = "lib"; + protected String apiVersion = "1.0.0"; + protected String apiDirName = "Api"; + /** * Configures the type of generator. * @@ -46,13 +57,8 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig super(); // set the output folder here - outputFolder = "generated-code/lumen"; - String packagePath = "lumen"; - - // modelPackage = packagePath + "\\lib\\Models"; - // apiPackage = packagePath + "\\lib"; - // // outputFolder = "generated-code" + File.separator + "slim"; - // modelTemplateFiles.put("model.mustache", ".php"); + outputFolder = "lumen"; + String packagePath = ""; /** * Models. You can write model files using the modelTemplateFiles map. @@ -75,7 +81,8 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig // no api files - apiTemplateFiles.clear(); + // apiTemplateFiles.clear(); + apiTemplateFiles.put("api.mustache", ".php"); // embeddedTemplateDir = templateDir = "slim"; @@ -115,43 +122,18 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig * 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("index.mustache", packagePath, "index.php")); - // supportingFiles.add(new SupportingFile("routes.mustache", packagePath, "routes.php")); - - supportingFiles.add(new SupportingFile("composer.json", packagePath, "composer.json")); + supportingFiles.add(new SupportingFile("composer.mustache", packagePath, "composer.json")); supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md")); - supportingFiles.add(new SupportingFile("artisan", packagePath, "artisan")); - // supportingFiles.add(new SupportingFile("server.php", packagePath, "server.php")); - - supportingFiles.add(new SupportingFile("bootstrap" + File.separator + "app.php", packagePath + File.separator + "bootstrap", "app.php")); - - supportingFiles.add(new SupportingFile("public" + File.separator + "index.php", packagePath + File.separator + "public", "index.php")); - - supportingFiles.add(new SupportingFile("app" + File.separator + "User.php", packagePath + File.separator + "app", "User.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Console" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Exceptions" + File.separator + "Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Http", "Kernel.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "routes.mustache", packagePath + File.separator + "app" + File.separator + "Http", "routes.php")); + supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + "bootstrap", "app.php")); + supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + "public", "index.php")); + supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + "app", "User.php")); + supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php")); + supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php")); + supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + "app" + File.separator + "Http", "routes.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "ExampleController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "ExampleController.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "AuthController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "AuthController.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "PasswordController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "PasswordController.php")); + supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php")); + supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "Authenticate.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "ExampleMiddleware.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "ExampleMiddleware.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "RedirectIfAuthenticated.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "RedirectIfAuthenticated.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "VerifyCsrfToken.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "VerifyCsrfToken.php")); - - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Requests" + File.separator + "Request.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Requests" + File.separator, "Request.php")); - - supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AppServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AppServiceProvider.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AuthServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AuthServiceProvider.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "EventServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "EventServiceProvider.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "RouteServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "RouteServiceProvider.php")); - - // supportingFiles.add(new SupportingFile("config" + File.separator + "app.php", packagePath + File.separator + "config" + File.separator, "app.php")); - /** * Language Specific Primitives. These types will not trigger imports by * the client generator @@ -188,7 +170,8 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig */ @Override public String apiFileFolder() { - return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); + return outputFolder + "/app/Http/controllers"; + // return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); } /** diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/Authenticate.php b/modules/swagger-codegen/src/main/resources/lumen/Authenticate.php similarity index 100% rename from modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/Authenticate.php rename to modules/swagger-codegen/src/main/resources/lumen/Authenticate.php diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Http/Controllers/Controller.php b/modules/swagger-codegen/src/main/resources/lumen/Controller.php similarity index 100% rename from modules/swagger-codegen/src/main/resources/lumen/app/Http/Controllers/Controller.php rename to modules/swagger-codegen/src/main/resources/lumen/Controller.php diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Exceptions/Handler.php b/modules/swagger-codegen/src/main/resources/lumen/Handler.php similarity index 100% rename from modules/swagger-codegen/src/main/resources/lumen/app/Exceptions/Handler.php rename to modules/swagger-codegen/src/main/resources/lumen/Handler.php diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Console/Kernel.php b/modules/swagger-codegen/src/main/resources/lumen/Kernel.php similarity index 100% rename from modules/swagger-codegen/src/main/resources/lumen/app/Console/Kernel.php rename to modules/swagger-codegen/src/main/resources/lumen/Kernel.php diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/User.php b/modules/swagger-codegen/src/main/resources/lumen/User.php similarity index 100% rename from modules/swagger-codegen/src/main/resources/lumen/app/User.php rename to modules/swagger-codegen/src/main/resources/lumen/User.php diff --git a/modules/swagger-codegen/src/main/resources/lumen/api.mustache b/modules/swagger-codegen/src/main/resources/lumen/api.mustache new file mode 100644 index 00000000000..fb735e2fb8e --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/api.mustache @@ -0,0 +1,108 @@ +licenseInfo}} + +namespace App\Http\Controllers; + +use Illuminate\Support\Facades\Request; + +{{#operations}}class {{classname}} extends Controller +{ + /** + * Constructor + */ + public function __construct() + { + } + + {{#operation}} + /** + * Operation {{{operationId}}} + * + * {{{summary}}}. + * + {{#pathParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + {{/pathParams}} * + * @return Http response + */ + public function {{operationId}}({{#pathParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}) + { + $input = Request::all(); + + //path params validation + {{#pathParams}} + {{#hasValidation}} + {{#maxLength}} + if (strlen(${{paramName}}]) > {{maxLength}}) { + throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); + } + {{/maxLength}} + {{#minLength}} + if (strlen(${{paramName}}]) < {{minLength}}) { + throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); + } + {{/minLength}} + {{#maximum}} + if (${{paramName}}] > {{maximum}}) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.'); + } + {{/maximum}} + {{#minimum}} + if (${{paramName}}] < {{minimum}}) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.'); + } + {{/minimum}} + {{#pattern}} + if (!preg_match("{{pattern}}", ${{paramName}}])) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.'); + } + {{/pattern}} + {{/hasValidation}} + {{/pathParams}} + + + //not path params validation + {{#allParams}} + {{^pathParams}} + {{#required}} + if (!isset($input['{{paramName}}'])) { + throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}'); + } + {{/required}} + {{#hasValidation}} + {{#maxLength}} + if (strlen($input['{{paramName}}']) > {{maxLength}}) { + throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); + } + {{/maxLength}} + {{#minLength}} + if (strlen($input['{{paramName}}']) < {{minLength}}) { + throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); + } + {{/minLength}} + {{#maximum}} + if ($input['{{paramName}}'] > {{maximum}}) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.'); + } + {{/maximum}} + {{#minimum}} + if ($input['{{paramName}}'] < {{minimum}}) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.'); + } + {{/minimum}} + {{#pattern}} + if (!preg_match("{{pattern}}", $input['{{paramName}}'])) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.'); + } + {{/pattern}} + {{/hasValidation}} + ${{paramName}} = $input['{{paramName}}']; + + {{/pathParams}} + {{/allParams}} + + return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); + } + {{/operation}} +} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php b/modules/swagger-codegen/src/main/resources/lumen/app.php similarity index 96% rename from modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php rename to modules/swagger-codegen/src/main/resources/lumen/app.php index 8f192282998..2811ed03ef9 100644 --- a/modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php +++ b/modules/swagger-codegen/src/main/resources/lumen/app.php @@ -41,7 +41,7 @@ $app = new Laravel\Lumen\Application( realpath(__DIR__.'/../') ); -// $app->withFacades(); +$app->withFacades(); // $app->withEloquent(); @@ -66,8 +66,6 @@ $app->singleton( App\Console\Kernel::class ); -class_alias('Illuminate\Support\Facades\Request', 'Request'); //to use the Reqesut facade - /* |-------------------------------------------------------------------------- | Register Middleware diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Console/Commands/.gitkeep b/modules/swagger-codegen/src/main/resources/lumen/app/Console/Commands/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Http/Controllers/ExampleController.php b/modules/swagger-codegen/src/main/resources/lumen/app/Http/Controllers/ExampleController.php deleted file mode 100644 index 60b47ac3a7a..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/app/Http/Controllers/ExampleController.php +++ /dev/null @@ -1,36 +0,0 @@ -licenseInfo}} -{{#apiInfo}}/** - * {{appName}} - * @version {{appVersion}} - */ - -$app->get('/', function () use ($app) { - return $app->version(); -}); - -{{#apis}} -{{#operations}} -{{#operation}} -/** - * {{httpMethod}} {{nickname}} - * Summary: {{summary}} - * Notes: {{notes}} -{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} - */ -$app->{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}$null = null) use ($app) { - $input = Request::all(); - - {{#allParams}} - {{#required}} - if (!isset($input['{{paramName}}'])) { - throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}'); - } - {{/required}} - {{#hasValidation}} - {{#maxLength}} - if (strlen($input['{{paramName}}']) > {{maxLength}}) { - throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); - } - {{/maxLength}} - {{#minLength}} - if (strlen($input['{{paramName}}']) < {{minLength}}) { - throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); - } - {{/minLength}} - {{#maximum}} - if ($input['{{paramName}}'] > {{maximum}}) { - throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.'); - } - {{/maximum}} - {{#minimum}} - if ($input['{{paramName}}'] < {{minimum}}) { - throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.'); - } - {{/minimum}} - {{#pattern}} - if (!preg_match("{{pattern}}", $input['{{paramName}}'])) { - throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.'); - } - {{/pattern}} - {{/hasValidation}} - ${{paramName}} = $input['{{paramName}}']; - - {{/allParams}} - return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); -}); - -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} - diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php b/modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php deleted file mode 100644 index 2c905bd129a..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php +++ /dev/null @@ -1,36 +0,0 @@ -input('api_token')) { - return User::where('api_token', $request->input('api_token'))->first(); - } - }); - } -} diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php b/modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php deleted file mode 100644 index 1efd71e2572..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php +++ /dev/null @@ -1,37 +0,0 @@ - [ - 'App\Listeners\EventListener', - ], - ]; -} diff --git a/modules/swagger-codegen/src/main/resources/lumen/composer.json b/modules/swagger-codegen/src/main/resources/lumen/composer.json deleted file mode 100644 index fa92a39def3..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/composer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "laravel/lumen", - "description": "The Laravel Lumen Framework.", - "keywords": ["framework", "laravel", "lumen"], - "license": "Apache-2.0", - "type": "project", - "require": { - "php": ">=5.5.9", - "laravel/lumen-framework": "5.2.*", - "vlucas/phpdotenv": "~2.2" - }, - "autoload": { - "psr-4": { - "App\\": "app/" - } - } -} diff --git a/modules/swagger-codegen/src/main/resources/lumen/composer.mustache b/modules/swagger-codegen/src/main/resources/lumen/composer.mustache new file mode 100644 index 00000000000..c3ae9fddfbf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/composer.mustache @@ -0,0 +1,31 @@ +{ + "name": "{{#composerVendorName}}{{.}}{{/composerVendorName}}{{^composerVendorName}}{{gitUserId}}{{/composerVendorName}}/{{#composerProjectName}}{{.}}{{/composerProjectName}}{{^composerProjectName}}{{gitRepoId}}{{/composerProjectName}}", + {{#artifactVersion}} + "version": "{{artifactVersion}}", + {{/artifactVersion}} + "description": "{{description}}", + "keywords": [ + "swagger", + "php", + "sdk", + "api" + ], + "homepage": "http://swagger.io", + "license": "Apache v2", + "authors": [ + { + "name": "Swagger and contributors", + "homepage": "https://github.com/swagger-api/swagger-codegen" + } + ], + "require": { + "php": ">=5.5.9", + "laravel/lumen-framework": "5.2.*", + "vlucas/phpdotenv": "~2.2" + }, + "autoload": { + "psr-4": { + "App\\": "app/" + } + } +} diff --git a/modules/swagger-codegen/src/main/resources/lumen/public/index.php b/modules/swagger-codegen/src/main/resources/lumen/index.php similarity index 100% rename from modules/swagger-codegen/src/main/resources/lumen/public/index.php rename to modules/swagger-codegen/src/main/resources/lumen/index.php diff --git a/modules/swagger-codegen/src/main/resources/lumen/public/.htaccess b/modules/swagger-codegen/src/main/resources/lumen/public/.htaccess deleted file mode 100644 index 8eb2dd0ddfa..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/public/.htaccess +++ /dev/null @@ -1,16 +0,0 @@ - - - Options -MultiViews - - - RewriteEngine On - - # Redirect Trailing Slashes If Not A Folder... - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^(.*)/$ /$1 [L,R=301] - - # Handle Front Controller... - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [L] - diff --git a/modules/swagger-codegen/src/main/resources/lumen/readme.md b/modules/swagger-codegen/src/main/resources/lumen/readme.md index b2507b4e564..c146781b7ae 100644 --- a/modules/swagger-codegen/src/main/resources/lumen/readme.md +++ b/modules/swagger-codegen/src/main/resources/lumen/readme.md @@ -1,18 +1,16 @@ -## Lumen PHP Framework +# Swagger generated server -[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework) -[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework) +## Overview +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the +[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This +is an example of building a PHP server. -Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching. +This example uses the [Lumen Framework](http://lumen.laravel.com/). To see how to make this your own, please take a look at the template here: -## Official Documentation +[TEMPLATES](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/slim/) -Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs). +## Installation & Usage +### Composer -## Security Vulnerabilities - -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. +Using `composer install` to install the framework and dependencies via [Composer](http://getcomposer.org/). diff --git a/modules/swagger-codegen/src/main/resources/lumen/routes.mustache b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache new file mode 100644 index 00000000000..c5f3bdf858a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache @@ -0,0 +1,27 @@ +licenseInfo}} +{{#apiInfo}}/** + * {{appName}} + * @version {{appVersion}} + */ + +$app->get('/', function () use ($app) { + return $app->version(); +}); + +{{#apis}} +{{#operations}} +{{#operation}} +/** + * {{httpMethod}} {{nickname}} + * Summary: {{summary}} + * Notes: {{notes}} +{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} + */ +$app->{{httpMethod}}('{{path}}', '{{classname}}@{{operationId}}'); +{{/operation}} +{{/operations}} +{{/apis}} +{{/apiInfo}} + diff --git a/modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore b/modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore deleted file mode 100644 index d6b7ef32c84..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore b/modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore deleted file mode 100644 index d6b7ef32c84..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore b/modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore deleted file mode 100644 index d6b7ef32c84..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php b/modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php deleted file mode 100644 index 2b206c66173..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $this->assertEquals( - $this->response->getContent(), $this->app->version() - ); - } -} diff --git a/modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php b/modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php deleted file mode 100644 index 651d9cbd67f..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php +++ /dev/null @@ -1,14 +0,0 @@ - 543.2) { + throw new \InvalidArgumentException('invalid value for $number when calling FakeApi.testEndpointParameters, must be smaller than or equal to 543.2.'); + } + if ($input['number'] < 32.1) { + throw new \InvalidArgumentException('invalid value for $number when calling FakeApi.testEndpointParameters, must be bigger than or equal to 32.1.'); + } + $number = $input['number']; + + if (!isset($input['double'])) { + throw new \InvalidArgumentException('Missing the required parameter $double when calling testEndpointParameters'); + } + if ($input['double'] > 123.4) { + throw new \InvalidArgumentException('invalid value for $double when calling FakeApi.testEndpointParameters, must be smaller than or equal to 123.4.'); + } + if ($input['double'] < 67.8) { + throw new \InvalidArgumentException('invalid value for $double when calling FakeApi.testEndpointParameters, must be bigger than or equal to 67.8.'); + } + $double = $input['double']; + + if (!isset($input['string'])) { + throw new \InvalidArgumentException('Missing the required parameter $string when calling testEndpointParameters'); + } + if (!preg_match("/[a-z]/i", $input['string'])) { + throw new \InvalidArgumentException('invalid value for $string when calling FakeApi.testEndpointParameters, must conform to the pattern /[a-z]/i.'); + } + $string = $input['string']; + + if (!isset($input['byte'])) { + throw new \InvalidArgumentException('Missing the required parameter $byte when calling testEndpointParameters'); + } + $byte = $input['byte']; + + if ($input['integer'] > 100.0) { + throw new \InvalidArgumentException('invalid value for $integer when calling FakeApi.testEndpointParameters, must be smaller than or equal to 100.0.'); + } + if ($input['integer'] < 10.0) { + throw new \InvalidArgumentException('invalid value for $integer when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.0.'); + } + $integer = $input['integer']; + + if ($input['int32'] > 200.0) { + throw new \InvalidArgumentException('invalid value for $int32 when calling FakeApi.testEndpointParameters, must be smaller than or equal to 200.0.'); + } + if ($input['int32'] < 20.0) { + throw new \InvalidArgumentException('invalid value for $int32 when calling FakeApi.testEndpointParameters, must be bigger than or equal to 20.0.'); + } + $int32 = $input['int32']; + + $int64 = $input['int64']; + + if ($input['float'] > 987.6) { + throw new \InvalidArgumentException('invalid value for $float when calling FakeApi.testEndpointParameters, must be smaller than or equal to 987.6.'); + } + $float = $input['float']; + + $binary = $input['binary']; + + $date = $input['date']; + + $dateTime = $input['dateTime']; + + if (strlen($input['password']) > 64) { + throw new \InvalidArgumentException('invalid length for $password when calling FakeApi.testEndpointParameters, must be smaller than or equal to 64.'); + } + if (strlen($input['password']) < 10) { + throw new \InvalidArgumentException('invalid length for $password when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); + } + $password = $input['password']; + + + return response('How about implementing testEndpointParameters as a POST method ?'); + } +} diff --git a/samples/server/petstore/lumen/app/Http/controllers/PetApi.php b/samples/server/petstore/lumen/app/Http/controllers/PetApi.php new file mode 100644 index 00000000000..dd6a838eaef --- /dev/null +++ b/samples/server/petstore/lumen/app/Http/controllers/PetApi.php @@ -0,0 +1,217 @@ + 5.0) { + throw new \InvalidArgumentException('invalid value for $orderId when calling StoreApi.getOrderById, must be smaller than or equal to 5.0.'); + } + if ($orderId] < 1.0) { + throw new \InvalidArgumentException('invalid value for $orderId when calling StoreApi.getOrderById, must be bigger than or equal to 1.0.'); + } + + + //not path params validation + + return response('How about implementing getOrderById as a GET method ?'); + } + /** + * Operation placeOrder + * + * Place an order for a pet. + * + * + * @return Http response + */ + public function placeOrder() + { + $input = Request::all(); + + //path params validation + + + //not path params validation + if (!isset($input['body'])) { + throw new \InvalidArgumentException('Missing the required parameter $body when calling placeOrder'); + } + $body = $input['body']; + + + return response('How about implementing placeOrder as a POST method ?'); + } +} diff --git a/samples/server/petstore/lumen/app/Http/controllers/UserApi.php b/samples/server/petstore/lumen/app/Http/controllers/UserApi.php new file mode 100644 index 00000000000..f9ade75e98a --- /dev/null +++ b/samples/server/petstore/lumen/app/Http/controllers/UserApi.php @@ -0,0 +1,221 @@ +get('/', function () use ($app) { + return $app->version(); +}); + +/** + * POST testEndpointParameters + * Summary: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Notes: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Output-Formats: [application/xml; charset=utf-8, application/json; charset=utf-8] + */ +$app->POST('/fake', 'FakeApi@testEndpointParameters'); +/** + * POST addPet + * Summary: Add a new pet to the store + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/pet', 'PetApi@addPet'); +/** + * DELETE deletePet + * Summary: Deletes a pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/pet/{petId}', 'PetApi@deletePet'); +/** + * 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('/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('/pet/findByTags', 'PetApi@findPetsByTags'); +/** + * GET getPetById + * Summary: Find pet by ID + * Notes: Returns a single pet + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/{petId}', 'PetApi@getPetById'); +/** + * PUT updatePet + * Summary: Update an existing pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->PUT('/pet', 'PetApi@updatePet'); +/** + * POST updatePetWithForm + * Summary: Updates a pet in the store with form data + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/pet/{petId}', 'PetApi@updatePetWithForm'); +/** + * POST uploadFile + * Summary: uploads an image + * Notes: + * Output-Formats: [application/json] + */ +$app->POST('/pet/{petId}/uploadImage', 'PetApi@uploadFile'); +/** + * 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 + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/store/order/{orderId}', 'StoreApi@deleteOrder'); +/** + * GET getInventory + * Summary: Returns pet inventories by status + * Notes: Returns a map of status codes to quantities + * Output-Formats: [application/json] + */ +$app->GET('/store/inventory', 'StoreApi@getInventory'); +/** + * 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('/store/order/{orderId}', 'StoreApi@getOrderById'); +/** + * POST placeOrder + * Summary: Place an order for a pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/store/order', 'StoreApi@placeOrder'); +/** + * POST createUser + * Summary: Create user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/user', 'UserApi@createUser'); +/** + * POST createUsersWithArrayInput + * Summary: Creates list of users with given input array + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/user/createWithArray', 'UserApi@createUsersWithArrayInput'); +/** + * POST createUsersWithListInput + * Summary: Creates list of users with given input array + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/user/createWithList', 'UserApi@createUsersWithListInput'); +/** + * DELETE deleteUser + * Summary: Delete user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/user/{username}', 'UserApi@deleteUser'); +/** + * GET getUserByName + * Summary: Get user by user name + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/{username}', 'UserApi@getUserByName'); +/** + * GET loginUser + * Summary: Logs user into the system + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/login', 'UserApi@loginUser'); +/** + * GET logoutUser + * Summary: Logs out current logged in user session + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/logout', 'UserApi@logoutUser'); +/** + * PUT updateUser + * Summary: Updated user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->PUT('/user/{username}', 'UserApi@updateUser'); + diff --git a/samples/server/petstore/lumen/lumen/app/User.php b/samples/server/petstore/lumen/app/User.php similarity index 100% rename from samples/server/petstore/lumen/lumen/app/User.php rename to samples/server/petstore/lumen/app/User.php diff --git a/samples/server/petstore/lumen/lumen/bootstrap/app.php b/samples/server/petstore/lumen/bootstrap/app.php similarity index 96% rename from samples/server/petstore/lumen/lumen/bootstrap/app.php rename to samples/server/petstore/lumen/bootstrap/app.php index 8f192282998..2811ed03ef9 100644 --- a/samples/server/petstore/lumen/lumen/bootstrap/app.php +++ b/samples/server/petstore/lumen/bootstrap/app.php @@ -41,7 +41,7 @@ $app = new Laravel\Lumen\Application( realpath(__DIR__.'/../') ); -// $app->withFacades(); +$app->withFacades(); // $app->withEloquent(); @@ -66,8 +66,6 @@ $app->singleton( App\Console\Kernel::class ); -class_alias('Illuminate\Support\Facades\Request', 'Request'); //to use the Reqesut facade - /* |-------------------------------------------------------------------------- | Register Middleware diff --git a/samples/server/petstore/lumen/composer.json b/samples/server/petstore/lumen/composer.json new file mode 100644 index 00000000000..55559dfaac9 --- /dev/null +++ b/samples/server/petstore/lumen/composer.json @@ -0,0 +1,28 @@ +{ + "name": "GIT_USER_ID/GIT_REPO_ID", + "description": "", + "keywords": [ + "swagger", + "php", + "sdk", + "api" + ], + "homepage": "http://swagger.io", + "license": "Apache v2", + "authors": [ + { + "name": "Swagger and contributors", + "homepage": "https://github.com/swagger-api/swagger-codegen" + } + ], + "require": { + "php": ">=5.5.9", + "laravel/lumen-framework": "5.2.*", + "vlucas/phpdotenv": "~2.2" + }, + "autoload": { + "psr-4": { + "App\\": "app/" + } + } +} diff --git a/samples/server/petstore/lumen/lumen/app/Http/Controllers/ExampleController.php b/samples/server/petstore/lumen/lumen/app/Http/Controllers/ExampleController.php deleted file mode 100644 index 60b47ac3a7a..00000000000 --- a/samples/server/petstore/lumen/lumen/app/Http/Controllers/ExampleController.php +++ /dev/null @@ -1,36 +0,0 @@ -get('/', function () use ($app) { - return $app->version(); -}); - -/** - * POST testEndpointParameters - * Summary: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * Notes: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * Output-Formats: [application/xml; charset=utf-8, application/json; charset=utf-8] - */ -$app->POST('/fake', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['number'])) { - throw new \InvalidArgumentException('Missing the required parameter $number when calling testEndpointParameters'); - } - if ($input['number'] > 543.2) { - throw new \InvalidArgumentException('invalid value for $number when calling FakeApi.testEndpointParameters, must be smaller than or equal to 543.2.'); - } - if ($input['number'] < 32.1) { - throw new \InvalidArgumentException('invalid value for $number when calling FakeApi.testEndpointParameters, must be bigger than or equal to 32.1.'); - } - $number = $input['number']; - - if (!isset($input['double'])) { - throw new \InvalidArgumentException('Missing the required parameter $double when calling testEndpointParameters'); - } - if ($input['double'] > 123.4) { - throw new \InvalidArgumentException('invalid value for $double when calling FakeApi.testEndpointParameters, must be smaller than or equal to 123.4.'); - } - if ($input['double'] < 67.8) { - throw new \InvalidArgumentException('invalid value for $double when calling FakeApi.testEndpointParameters, must be bigger than or equal to 67.8.'); - } - $double = $input['double']; - - if (!isset($input['string'])) { - throw new \InvalidArgumentException('Missing the required parameter $string when calling testEndpointParameters'); - } - if (!preg_match("/[a-z]/i", $input['string'])) { - throw new \InvalidArgumentException('invalid value for $string when calling FakeApi.testEndpointParameters, must conform to the pattern /[a-z]/i.'); - } - $string = $input['string']; - - if (!isset($input['byte'])) { - throw new \InvalidArgumentException('Missing the required parameter $byte when calling testEndpointParameters'); - } - $byte = $input['byte']; - - if ($input['integer'] > 100.0) { - throw new \InvalidArgumentException('invalid value for $integer when calling FakeApi.testEndpointParameters, must be smaller than or equal to 100.0.'); - } - if ($input['integer'] < 10.0) { - throw new \InvalidArgumentException('invalid value for $integer when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.0.'); - } - $integer = $input['integer']; - - if ($input['int32'] > 200.0) { - throw new \InvalidArgumentException('invalid value for $int32 when calling FakeApi.testEndpointParameters, must be smaller than or equal to 200.0.'); - } - if ($input['int32'] < 20.0) { - throw new \InvalidArgumentException('invalid value for $int32 when calling FakeApi.testEndpointParameters, must be bigger than or equal to 20.0.'); - } - $int32 = $input['int32']; - - $int64 = $input['int64']; - - if ($input['float'] > 987.6) { - throw new \InvalidArgumentException('invalid value for $float when calling FakeApi.testEndpointParameters, must be smaller than or equal to 987.6.'); - } - $float = $input['float']; - - $binary = $input['binary']; - - $date = $input['date']; - - $dateTime = $input['dateTime']; - - if (strlen($input['password']) > 64) { - throw new \InvalidArgumentException('invalid length for $password when calling FakeApi.testEndpointParameters, must be smaller than or equal to 64.'); - } - if (strlen($input['password']) < 10) { - throw new \InvalidArgumentException('invalid length for $password when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); - } - $password = $input['password']; - - return response('How about implementing testEndpointParameters as a POST method ?'); -}); - -/** - * POST addPet - * Summary: Add a new pet to the store - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/pet', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['body'])) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling addPet'); - } - $body = $input['body']; - - return response('How about implementing addPet as a POST method ?'); -}); - -/** - * DELETE deletePet - * Summary: Deletes a pet - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->DELETE('/pet/{petId}', function($petId, $null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['petId'])) { - throw new \InvalidArgumentException('Missing the required parameter $petId when calling deletePet'); - } - $petId = $input['petId']; - - $apiKey = $input['apiKey']; - - return response('How about implementing deletePet as a DELETE method ?'); -}); - -/** - * 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('/pet/findByStatus', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['status'])) { - throw new \InvalidArgumentException('Missing the required parameter $status when calling findPetsByStatus'); - } - $status = $input['status']; - - return response('How about implementing findPetsByStatus as a GET method ?'); -}); - -/** - * 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('/pet/findByTags', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['tags'])) { - throw new \InvalidArgumentException('Missing the required parameter $tags when calling findPetsByTags'); - } - $tags = $input['tags']; - - return response('How about implementing findPetsByTags as a GET method ?'); -}); - -/** - * GET getPetById - * Summary: Find pet by ID - * Notes: Returns a single pet - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/pet/{petId}', function($petId, $null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['petId'])) { - throw new \InvalidArgumentException('Missing the required parameter $petId when calling getPetById'); - } - $petId = $input['petId']; - - return response('How about implementing getPetById as a GET method ?'); -}); - -/** - * PUT updatePet - * Summary: Update an existing pet - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->PUT('/pet', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['body'])) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling updatePet'); - } - $body = $input['body']; - - return response('How about implementing updatePet as a PUT method ?'); -}); - -/** - * POST updatePetWithForm - * Summary: Updates a pet in the store with form data - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/pet/{petId}', function($petId, $null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['petId'])) { - throw new \InvalidArgumentException('Missing the required parameter $petId when calling updatePetWithForm'); - } - $petId = $input['petId']; - - $name = $input['name']; - - $status = $input['status']; - - return response('How about implementing updatePetWithForm as a POST method ?'); -}); - -/** - * POST uploadFile - * Summary: uploads an image - * Notes: - * Output-Formats: [application/json] - */ -$app->POST('/pet/{petId}/uploadImage', function($petId, $null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['petId'])) { - throw new \InvalidArgumentException('Missing the required parameter $petId when calling uploadFile'); - } - $petId = $input['petId']; - - $additionalMetadata = $input['additionalMetadata']; - - $file = $input['file']; - - return response('How about implementing uploadFile as a POST method ?'); -}); - -/** - * 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 - * Output-Formats: [application/xml, application/json] - */ -$app->DELETE('/store/order/{orderId}', function($orderId, $null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['orderId'])) { - throw new \InvalidArgumentException('Missing the required parameter $orderId when calling deleteOrder'); - } - if ($input['orderId'] < 1.0) { - throw new \InvalidArgumentException('invalid value for $orderId when calling StoreApi.deleteOrder, must be bigger than or equal to 1.0.'); - } - $orderId = $input['orderId']; - - return response('How about implementing deleteOrder as a DELETE method ?'); -}); - -/** - * GET getInventory - * Summary: Returns pet inventories by status - * Notes: Returns a map of status codes to quantities - * Output-Formats: [application/json] - */ -$app->GET('/store/inventory', function($null = null) use ($app) { - $input = Request::all(); - - return response('How about implementing getInventory as a GET method ?'); -}); - -/** - * 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('/store/order/{orderId}', function($orderId, $null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['orderId'])) { - throw new \InvalidArgumentException('Missing the required parameter $orderId when calling getOrderById'); - } - if ($input['orderId'] > 5.0) { - throw new \InvalidArgumentException('invalid value for $orderId when calling StoreApi.getOrderById, must be smaller than or equal to 5.0.'); - } - if ($input['orderId'] < 1.0) { - throw new \InvalidArgumentException('invalid value for $orderId when calling StoreApi.getOrderById, must be bigger than or equal to 1.0.'); - } - $orderId = $input['orderId']; - - return response('How about implementing getOrderById as a GET method ?'); -}); - -/** - * POST placeOrder - * Summary: Place an order for a pet - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/store/order', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['body'])) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling placeOrder'); - } - $body = $input['body']; - - return response('How about implementing placeOrder as a POST method ?'); -}); - -/** - * POST createUser - * Summary: Create user - * Notes: This can only be done by the logged in user. - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/user', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['body'])) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling createUser'); - } - $body = $input['body']; - - return response('How about implementing createUser as a POST method ?'); -}); - -/** - * POST createUsersWithArrayInput - * Summary: Creates list of users with given input array - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/user/createWithArray', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['body'])) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling createUsersWithArrayInput'); - } - $body = $input['body']; - - return response('How about implementing createUsersWithArrayInput as a POST method ?'); -}); - -/** - * POST createUsersWithListInput - * Summary: Creates list of users with given input array - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/user/createWithList', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['body'])) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling createUsersWithListInput'); - } - $body = $input['body']; - - return response('How about implementing createUsersWithListInput as a POST method ?'); -}); - -/** - * DELETE deleteUser - * Summary: Delete user - * Notes: This can only be done by the logged in user. - * Output-Formats: [application/xml, application/json] - */ -$app->DELETE('/user/{username}', function($username, $null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['username'])) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser'); - } - $username = $input['username']; - - return response('How about implementing deleteUser as a DELETE method ?'); -}); - -/** - * GET getUserByName - * Summary: Get user by user name - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/user/{username}', function($username, $null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['username'])) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName'); - } - $username = $input['username']; - - return response('How about implementing getUserByName as a GET method ?'); -}); - -/** - * GET loginUser - * Summary: Logs user into the system - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/user/login', function($null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['username'])) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling loginUser'); - } - $username = $input['username']; - - if (!isset($input['password'])) { - throw new \InvalidArgumentException('Missing the required parameter $password when calling loginUser'); - } - $password = $input['password']; - - return response('How about implementing loginUser as a GET method ?'); -}); - -/** - * GET logoutUser - * Summary: Logs out current logged in user session - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/user/logout', function($null = null) use ($app) { - $input = Request::all(); - - return response('How about implementing logoutUser as a GET method ?'); -}); - -/** - * PUT updateUser - * Summary: Updated user - * Notes: This can only be done by the logged in user. - * Output-Formats: [application/xml, application/json] - */ -$app->PUT('/user/{username}', function($username, $null = null) use ($app) { - $input = Request::all(); - - if (!isset($input['username'])) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling updateUser'); - } - $username = $input['username']; - - if (!isset($input['body'])) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling updateUser'); - } - $body = $input['body']; - - return response('How about implementing updateUser as a PUT method ?'); -}); - - diff --git a/samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php b/samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php deleted file mode 100644 index 2c905bd129a..00000000000 --- a/samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php +++ /dev/null @@ -1,36 +0,0 @@ -input('api_token')) { - return User::where('api_token', $request->input('api_token'))->first(); - } - }); - } -} diff --git a/samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php b/samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php deleted file mode 100644 index 1efd71e2572..00000000000 --- a/samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php +++ /dev/null @@ -1,37 +0,0 @@ - [ - 'App\Listeners\EventListener', - ], - ]; -} diff --git a/samples/server/petstore/lumen/lumen/artisan b/samples/server/petstore/lumen/lumen/artisan deleted file mode 100644 index 6a9d095aeae..00000000000 --- a/samples/server/petstore/lumen/lumen/artisan +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env php -make( - 'Illuminate\Contracts\Console\Kernel' -); - -exit($kernel->handle(new ArgvInput, new ConsoleOutput)); diff --git a/samples/server/petstore/lumen/lumen/composer.json b/samples/server/petstore/lumen/lumen/composer.json deleted file mode 100644 index fa92a39def3..00000000000 --- a/samples/server/petstore/lumen/lumen/composer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "laravel/lumen", - "description": "The Laravel Lumen Framework.", - "keywords": ["framework", "laravel", "lumen"], - "license": "Apache-2.0", - "type": "project", - "require": { - "php": ">=5.5.9", - "laravel/lumen-framework": "5.2.*", - "vlucas/phpdotenv": "~2.2" - }, - "autoload": { - "psr-4": { - "App\\": "app/" - } - } -} diff --git a/samples/server/petstore/lumen/lumen/readme.md b/samples/server/petstore/lumen/lumen/readme.md deleted file mode 100644 index b2507b4e564..00000000000 --- a/samples/server/petstore/lumen/lumen/readme.md +++ /dev/null @@ -1,18 +0,0 @@ -## Lumen PHP Framework - -[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework) -[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework) - -Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching. - -## Official Documentation - -Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs). - -## Security Vulnerabilities - -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. - diff --git a/samples/server/petstore/lumen/lumen/public/index.php b/samples/server/petstore/lumen/public/index.php similarity index 100% rename from samples/server/petstore/lumen/lumen/public/index.php rename to samples/server/petstore/lumen/public/index.php diff --git a/samples/server/petstore/lumen/readme.md b/samples/server/petstore/lumen/readme.md new file mode 100644 index 00000000000..c146781b7ae --- /dev/null +++ b/samples/server/petstore/lumen/readme.md @@ -0,0 +1,16 @@ +# Swagger generated server + +## Overview +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the +[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This +is an example of building a PHP server. + +This example uses the [Lumen Framework](http://lumen.laravel.com/). To see how to make this your own, please take a look at the template here: + +[TEMPLATES](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/slim/) + +## Installation & Usage +### Composer + +Using `composer install` to install the framework and dependencies via [Composer](http://getcomposer.org/). +