add lumen api.mustache to generate controller & license update & resource dir restructure

This commit is contained in:
abcsun 2016-06-17 11:37:10 +08:00
parent ee024c40fb
commit 0effbae24b
49 changed files with 1136 additions and 1163 deletions

View File

@ -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);
}
/**

View File

@ -0,0 +1,108 @@
<?php
{{>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}}

View File

@ -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

View File

@ -1,36 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Http\Controllers;
class ExampleController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//
}
//
}

View File

@ -1,38 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Http\Middleware;
use Closure;
class ExampleMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $next($request);
}
}

View File

@ -1,68 +0,0 @@
<?php
{{>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}}

View File

@ -1,36 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

View File

@ -1,58 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Providers;
use App\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Boot the authentication services for the application.
*
* @return void
*/
public function boot()
{
// Here you may define how you wish users to be authenticated for your Lumen
// application. The callback which receives the incoming request instance
// should return either a User instance or null. You're free to obtain
// the User instance via an API token or any other method necessary.
Auth::viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return User::where('api_token', $request->input('api_token'))->first();
}
});
}
}

View File

@ -1,37 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Providers;
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
],
];
}

View File

@ -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/"
}
}
}

View File

@ -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/"
}
}
}

View File

@ -1,16 +0,0 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
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]
</IfModule>

View File

@ -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/).

View File

@ -0,0 +1,27 @@
<?php
{{>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}}

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,20 +0,0 @@
<?php
use Laravel\Lumen\Testing\DatabaseTransactions;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->get('/');
$this->assertEquals(
$this->response->getContent(), $this->app->version()
);
}
}

View File

@ -1,14 +0,0 @@
<?php
class TestCase extends Laravel\Lumen\Testing\TestCase
{
/**
* Creates the application.
*
* @return \Laravel\Lumen\Application
*/
public function createApplication()
{
return require __DIR__.'/../bootstrap/app.php';
}
}

View File

@ -0,0 +1,132 @@
<?php
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Request;
class FakeApi extends Controller
{
/**
* Constructor
*/
public function __construct()
{
}
/**
* Operation testEndpointParameters
*
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 .
*
*
* @return Http response
*/
public function testEndpointParameters()
{
$input = Request::all();
//path params validation
//not path params validation
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 ?');
}
}

View File

@ -0,0 +1,217 @@
<?php
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Request;
class PetApi extends Controller
{
/**
* Constructor
*/
public function __construct()
{
}
/**
* Operation addPet
*
* Add a new pet to the store.
*
*
* @return Http response
*/
public function addPet()
{
$input = Request::all();
//path params validation
//not path params validation
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 ?');
}
/**
* Operation deletePet
*
* Deletes a pet.
*
* @param Long $petId Pet id to delete (required)
*
* @return Http response
*/
public function deletePet($petId)
{
$input = Request::all();
//path params validation
//not path params validation
return response('How about implementing deletePet as a DELETE method ?');
}
/**
* Operation findPetsByStatus
*
* Finds Pets by status.
*
*
* @return Http response
*/
public function findPetsByStatus()
{
$input = Request::all();
//path params validation
//not path params validation
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 ?');
}
/**
* Operation findPetsByTags
*
* Finds Pets by tags.
*
*
* @return Http response
*/
public function findPetsByTags()
{
$input = Request::all();
//path params validation
//not path params validation
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 ?');
}
/**
* Operation getPetById
*
* Find pet by ID.
*
* @param Long $petId ID of pet to return (required)
*
* @return Http response
*/
public function getPetById($petId)
{
$input = Request::all();
//path params validation
//not path params validation
return response('How about implementing getPetById as a GET method ?');
}
/**
* Operation updatePet
*
* Update an existing pet.
*
*
* @return Http response
*/
public function updatePet()
{
$input = Request::all();
//path params validation
//not path params validation
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 ?');
}
/**
* Operation updatePetWithForm
*
* Updates a pet in the store with form data.
*
* @param Long $petId ID of pet that needs to be updated (required)
*
* @return Http response
*/
public function updatePetWithForm($petId)
{
$input = Request::all();
//path params validation
//not path params validation
return response('How about implementing updatePetWithForm as a POST method ?');
}
/**
* Operation uploadFile
*
* uploads an image.
*
* @param Long $petId ID of pet to update (required)
*
* @return Http response
*/
public function uploadFile($petId)
{
$input = Request::all();
//path params validation
//not path params validation
return response('How about implementing uploadFile as a POST method ?');
}
}

View File

@ -0,0 +1,133 @@
<?php
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Request;
class StoreApi extends Controller
{
/**
* Constructor
*/
public function __construct()
{
}
/**
* Operation deleteOrder
*
* Delete purchase order by ID.
*
* @param String $orderId ID of the order that needs to be deleted (required)
*
* @return Http response
*/
public function deleteOrder($orderId)
{
$input = Request::all();
//path params validation
if ($orderId] < 1.0) {
throw new \InvalidArgumentException('invalid value for $orderId when calling StoreApi.deleteOrder, must be bigger than or equal to 1.0.');
}
//not path params validation
return response('How about implementing deleteOrder as a DELETE method ?');
}
/**
* Operation getInventory
*
* Returns pet inventories by status.
*
*
* @return Http response
*/
public function getInventory()
{
$input = Request::all();
//path params validation
//not path params validation
return response('How about implementing getInventory as a GET method ?');
}
/**
* Operation getOrderById
*
* Find purchase order by ID.
*
* @param Long $orderId ID of pet that needs to be fetched (required)
*
* @return Http response
*/
public function getOrderById($orderId)
{
$input = Request::all();
//path params validation
if ($orderId] > 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 ?');
}
}

View File

@ -0,0 +1,221 @@
<?php
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Request;
class UserApi extends Controller
{
/**
* Constructor
*/
public function __construct()
{
}
/**
* Operation createUser
*
* Create user.
*
*
* @return Http response
*/
public function createUser()
{
$input = Request::all();
//path params validation
//not path params validation
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 ?');
}
/**
* Operation createUsersWithArrayInput
*
* Creates list of users with given input array.
*
*
* @return Http response
*/
public function createUsersWithArrayInput()
{
$input = Request::all();
//path params validation
//not path params validation
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 ?');
}
/**
* Operation createUsersWithListInput
*
* Creates list of users with given input array.
*
*
* @return Http response
*/
public function createUsersWithListInput()
{
$input = Request::all();
//path params validation
//not path params validation
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 ?');
}
/**
* Operation deleteUser
*
* Delete user.
*
* @param String $username The name that needs to be deleted (required)
*
* @return Http response
*/
public function deleteUser($username)
{
$input = Request::all();
//path params validation
//not path params validation
return response('How about implementing deleteUser as a DELETE method ?');
}
/**
* Operation getUserByName
*
* Get user by user name.
*
* @param String $username The name that needs to be fetched. Use user1 for testing. (required)
*
* @return Http response
*/
public function getUserByName($username)
{
$input = Request::all();
//path params validation
//not path params validation
return response('How about implementing getUserByName as a GET method ?');
}
/**
* Operation loginUser
*
* Logs user into the system.
*
*
* @return Http response
*/
public function loginUser()
{
$input = Request::all();
//path params validation
//not path params validation
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 ?');
}
/**
* Operation logoutUser
*
* Logs out current logged in user session.
*
*
* @return Http response
*/
public function logoutUser()
{
$input = Request::all();
//path params validation
//not path params validation
return response('How about implementing logoutUser as a GET method ?');
}
/**
* Operation updateUser
*
* Updated user.
*
* @param String $username name that need to be deleted (required)
*
* @return Http response
*/
public function updateUser($username)
{
$input = Request::all();
//path params validation
//not path params validation
return response('How about implementing updateUser as a PUT method ?');
}
}

View File

@ -0,0 +1,183 @@
<?php
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Swagger Petstore
* @version 1.0.0
*/
$app->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 &lt; 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 &lt;&#x3D; 5 or &gt; 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');

View File

@ -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

View File

@ -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/"
}
}
}

View File

@ -1,36 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Http\Controllers;
class ExampleController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//
}
//
}

View File

@ -1,38 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Http\Middleware;
use Closure;
class ExampleMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $next($request);
}
}

View File

@ -1,479 +0,0 @@
<?php
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Swagger Petstore
* @version 1.0.0
*/
$app->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 &lt; 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 &lt;&#x3D; 5 or &gt; 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 ?');
});

View File

@ -1,36 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

View File

@ -1,58 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Providers;
use App\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Boot the authentication services for the application.
*
* @return void
*/
public function boot()
{
// Here you may define how you wish users to be authenticated for your Lumen
// application. The callback which receives the incoming request instance
// should return either a User instance or null. You're free to obtain
// the User instance via an API token or any other method necessary.
Auth::viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return User::where('api_token', $request->input('api_token'))->first();
}
});
}
}

View File

@ -1,37 +0,0 @@
<?php
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace App\Providers;
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
],
];
}

View File

@ -1,35 +0,0 @@
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
*/
$app = require __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(
'Illuminate\Contracts\Console\Kernel'
);
exit($kernel->handle(new ArgvInput, new ConsoleOutput));

View File

@ -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/"
}
}
}

View File

@ -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.

View File

@ -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/).