forked from loafle/openapi-generator-original
update the routes.mustache
This commit is contained in:
parent
a037af1b72
commit
1b71597e84
@ -49,10 +49,10 @@ public class LumenservercodegenGenerator extends DefaultCodegen implements Codeg
|
||||
outputFolder = "generated-code/LumenServerCodegen";
|
||||
String packagePath = "SwaggerServer";
|
||||
|
||||
modelPackage = packagePath + "\\lib\\Models";
|
||||
apiPackage = packagePath + "\\lib";
|
||||
// outputFolder = "generated-code" + File.separator + "slim";
|
||||
modelTemplateFiles.put("model.mustache", ".php");
|
||||
// modelPackage = packagePath + "\\lib\\Models";
|
||||
// apiPackage = packagePath + "\\lib";
|
||||
// // outputFolder = "generated-code" + File.separator + "slim";
|
||||
// modelTemplateFiles.put("model.mustache", ".php");
|
||||
|
||||
/**
|
||||
* Models. You can write model files using the modelTemplateFiles map.
|
||||
@ -116,7 +116,7 @@ public class LumenservercodegenGenerator extends DefaultCodegen implements Codeg
|
||||
* 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("route.mustache", packagePath, "route.php"));
|
||||
// supportingFiles.add(new SupportingFile("routes.mustache", packagePath, "routes.php"));
|
||||
|
||||
supportingFiles.add(new SupportingFile("composer.json", packagePath, "composer.json"));
|
||||
supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md"));
|
||||
@ -131,7 +131,7 @@ public class LumenservercodegenGenerator extends DefaultCodegen implements Codeg
|
||||
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.php", packagePath + File.separator + "app" + File.separator + "Http", "routes.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" + 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"));
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
{{#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) {
|
||||
{{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}}
|
||||
{{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}}
|
||||
{{/queryParams}}{{/hasQueryParams}}
|
||||
{{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}}
|
||||
|
||||
return response('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
||||
});
|
||||
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register all of the routes for an application.
|
||||
| It is a breeze. Simply tell Lumen the URIs it should respond to
|
||||
| and give it the Closure to call when that URI is requested.
|
||||
|
|
||||
*/
|
||||
|
||||
$app->get('/', function () use ($app) {
|
||||
return $app->version();
|
||||
});
|
@ -48,6 +48,8 @@ $app->singleton(
|
||||
App\Console\Kernel::class
|
||||
);
|
||||
|
||||
class_alias('Illuminate\Support\Facades\Request', 'Request'); //to use the Reqesut facade
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Middleware
|
||||
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
{{#apiInfo}}/**
|
||||
* {{appName}}
|
||||
* @version {{appVersion}}
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$app = new Slim\App();
|
||||
|
||||
{{#apis}}{{#operations}}{{#operation}}
|
||||
/**
|
||||
* {{httpMethod}} {{nickname}}
|
||||
* Summary: {{summary}}
|
||||
* Notes: {{notes}}
|
||||
{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
|
||||
*/
|
||||
$app->{{httpMethod}}('{{path}}', function($request, $response, $args) {
|
||||
{{#hasHeaderParams}}$headers = $request->getHeaders();{{/hasHeaderParams}}
|
||||
{{#hasQueryParams}}$queryParams = $request->getQueryParams();
|
||||
{{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}}
|
||||
{{#hasFormParams}}{{#formParams}}${{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}}
|
||||
{{#hasBodyParam}}$body = $request->getParsedBody();{{/hasBodyParam}}
|
||||
$response->write('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
$app->run();
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
{{#models}}{{#model}}/*
|
||||
* {{classname}}
|
||||
*/
|
||||
namespace {{package}};
|
||||
|
||||
/*
|
||||
* {{classname}}
|
||||
*/
|
||||
class {{classname}} {
|
||||
{{#vars}}/* @var {{datatype}} ${{name}} {{#description}}{{description}}{{/description}} */
|
||||
private ${{name}};
|
||||
{{/vars}}
|
||||
}
|
||||
{{/model}}{{/models}}
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="bootstrap/app.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false">
|
||||
<testsuites>
|
||||
<testsuite name="Application Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">app/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
</php>
|
||||
</phpunit>
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
{{#apiInfo}}/**
|
||||
* {{appName}}
|
||||
* @version {{appVersion}}
|
||||
*/
|
||||
|
||||
|
||||
{{#apis}}{{#operations}}{{#operation}}
|
||||
/**
|
||||
* {{httpMethod}} {{nickname}}
|
||||
* Summary: {{summary}}
|
||||
* Notes: {{notes}}
|
||||
{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
|
||||
*/
|
||||
Route::{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}} {{/pathParams}}) use ($app) {
|
||||
{{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}}
|
||||
|
||||
{{#hasQueryParams}}$queryParams = $request->getQueryParams();
|
||||
{{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}}
|
||||
|
||||
{{#hasQueryParams}}$inputs = Request::all();
|
||||
{{#inputs}}${{paramName}} = $inputs['{{paramName}}'];{{newline}}
|
||||
{{/inputs}}{{/hasQueryParams}}
|
||||
|
||||
{{#hasFormParams}}{{#formParams}}${{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}}
|
||||
{{#hasBodyParam}}$body = $app->request->getParsedBody();{{/hasBodyParam}}
|
||||
return response('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
||||
});
|
||||
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
{{#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}}
|
||||
*/
|
||||
Route::{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}null) use ($app) {
|
||||
{{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}}
|
||||
{{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}}
|
||||
{{/queryParams}}{{/hasQueryParams}}
|
||||
{{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}}
|
||||
|
||||
return response('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
||||
});
|
||||
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user