forked from loafle/openapi-generator-original
feat (PHP LARAVEL) 8417: initial PHP-laravel codegen integration (#574)
* feat (PHP LARAVEL) 8417: initial PHP-laravel codegen integration * feat (PHP LARAVEL) 8417: code review adjustments * feat (PHP LARAVEL) 8417: fix typos; add missing files; adjust readme for those unfamilar with laravel to get started quickly * feat (PHP LARAVEL) 8417: add sample petstore server * feat (PHP LARAVEL) 8417: adjust route service provdider and model generation
This commit is contained in:
committed by
William Cheng
parent
d1fc923b66
commit
f793ac25c7
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* OpenAPI 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Source files are located at:
|
||||
*
|
||||
* > swagger-codegen/modules/swagger-codegen/src/main/resources/php-laravel/
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
class AnotherFakeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation testSpecialTags
|
||||
*
|
||||
* To test special tags.
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function testSpecialTags()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
if (!isset($input['client'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $client when calling testSpecialTags');
|
||||
}
|
||||
$client = $input['client'];
|
||||
|
||||
|
||||
return response('How about implementing testSpecialTags as a patch method ?');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
/**
|
||||
* Class Controller
|
||||
*
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function welcome()
|
||||
{
|
||||
return view('welcome');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* OpenAPI 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Source files are located at:
|
||||
*
|
||||
* > swagger-codegen/modules/swagger-codegen/src/main/resources/php-laravel/
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
class FakeClassnameTags123Controller extends Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation testClassname
|
||||
*
|
||||
* To test class name in snake case.
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function testClassname()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
if (!isset($input['client'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $client when calling testClassname');
|
||||
}
|
||||
$client = $input['client'];
|
||||
|
||||
|
||||
return response('How about implementing testClassname as a patch method ?');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* OpenAPI 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Source files are located at:
|
||||
*
|
||||
* > swagger-codegen/modules/swagger-codegen/src/main/resources/php-laravel/
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
class FakeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation testClientModel
|
||||
*
|
||||
* To test \"client\" model.
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function testClientModel()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
if (!isset($input['client'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $client when calling testClientModel');
|
||||
}
|
||||
$client = $input['client'];
|
||||
|
||||
|
||||
return response('How about implementing testClientModel as a patch method ?');
|
||||
}
|
||||
/**
|
||||
* 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 FakeController.testEndpointParameters, must be smaller than or equal to 543.2.');
|
||||
}
|
||||
if ($input['number'] < 32.1) {
|
||||
throw new \InvalidArgumentException('invalid value for $number when calling FakeController.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 FakeController.testEndpointParameters, must be smaller than or equal to 123.4.');
|
||||
}
|
||||
if ($input['double'] < 67.8) {
|
||||
throw new \InvalidArgumentException('invalid value for $double when calling FakeController.testEndpointParameters, must be bigger than or equal to 67.8.');
|
||||
}
|
||||
$double = $input['double'];
|
||||
|
||||
if (!isset($input['pattern_without_delimiter'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $pattern_without_delimiter when calling testEndpointParameters');
|
||||
}
|
||||
if (!preg_match("/^[A-Z].*/", $input['pattern_without_delimiter'])) {
|
||||
throw new \InvalidArgumentException('invalid value for $pattern_without_delimiter when calling FakeController.testEndpointParameters, must conform to the pattern /^[A-Z].*/.');
|
||||
}
|
||||
$pattern_without_delimiter = $input['pattern_without_delimiter'];
|
||||
|
||||
if (!isset($input['byte'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $byte when calling testEndpointParameters');
|
||||
}
|
||||
$byte = $input['byte'];
|
||||
|
||||
if ($input['integer'] > 100) {
|
||||
throw new \InvalidArgumentException('invalid value for $integer when calling FakeController.testEndpointParameters, must be smaller than or equal to 100.');
|
||||
}
|
||||
if ($input['integer'] < 10) {
|
||||
throw new \InvalidArgumentException('invalid value for $integer when calling FakeController.testEndpointParameters, must be bigger than or equal to 10.');
|
||||
}
|
||||
$integer = $input['integer'];
|
||||
|
||||
if ($input['int32'] > 200) {
|
||||
throw new \InvalidArgumentException('invalid value for $int32 when calling FakeController.testEndpointParameters, must be smaller than or equal to 200.');
|
||||
}
|
||||
if ($input['int32'] < 20) {
|
||||
throw new \InvalidArgumentException('invalid value for $int32 when calling FakeController.testEndpointParameters, must be bigger than or equal to 20.');
|
||||
}
|
||||
$int32 = $input['int32'];
|
||||
|
||||
$int64 = $input['int64'];
|
||||
|
||||
if ($input['float'] > 987.6) {
|
||||
throw new \InvalidArgumentException('invalid value for $float when calling FakeController.testEndpointParameters, must be smaller than or equal to 987.6.');
|
||||
}
|
||||
$float = $input['float'];
|
||||
|
||||
if (!preg_match("/[a-z]/i", $input['string'])) {
|
||||
throw new \InvalidArgumentException('invalid value for $string when calling FakeController.testEndpointParameters, must conform to the pattern /[a-z]/i.');
|
||||
}
|
||||
$string = $input['string'];
|
||||
|
||||
$binary = $input['binary'];
|
||||
|
||||
$date = $input['date'];
|
||||
|
||||
$date_time = $input['date_time'];
|
||||
|
||||
if (strlen($input['password']) > 64) {
|
||||
throw new \InvalidArgumentException('invalid length for $password when calling FakeController.testEndpointParameters, must be smaller than or equal to 64.');
|
||||
}
|
||||
if (strlen($input['password']) < 10) {
|
||||
throw new \InvalidArgumentException('invalid length for $password when calling FakeController.testEndpointParameters, must be bigger than or equal to 10.');
|
||||
}
|
||||
$password = $input['password'];
|
||||
|
||||
$callback = $input['callback'];
|
||||
|
||||
|
||||
return response('How about implementing testEndpointParameters as a post method ?');
|
||||
}
|
||||
/**
|
||||
* Operation testEnumParameters
|
||||
*
|
||||
* To test enum parameters.
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function testEnumParameters()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
$enum_header_string_array = $input['enum_header_string_array'];
|
||||
|
||||
$enum_header_string = $input['enum_header_string'];
|
||||
|
||||
$enum_query_string_array = $input['enum_query_string_array'];
|
||||
|
||||
$enum_query_string = $input['enum_query_string'];
|
||||
|
||||
$enum_query_integer = $input['enum_query_integer'];
|
||||
|
||||
$enum_query_double = $input['enum_query_double'];
|
||||
|
||||
$enum_form_string_array = $input['enum_form_string_array'];
|
||||
|
||||
$enum_form_string = $input['enum_form_string'];
|
||||
|
||||
|
||||
return response('How about implementing testEnumParameters as a get method ?');
|
||||
}
|
||||
/**
|
||||
* Operation testBodyWithFileSchema
|
||||
*
|
||||
* .
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function testBodyWithFileSchema()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
if (!isset($input['file_schema_test_class'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $file_schema_test_class when calling testBodyWithFileSchema');
|
||||
}
|
||||
$file_schema_test_class = $input['file_schema_test_class'];
|
||||
|
||||
|
||||
return response('How about implementing testBodyWithFileSchema as a put method ?');
|
||||
}
|
||||
/**
|
||||
* Operation testBodyWithQueryParams
|
||||
*
|
||||
* .
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function testBodyWithQueryParams()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
if (!isset($input['query'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $query when calling testBodyWithQueryParams');
|
||||
}
|
||||
$query = $input['query'];
|
||||
|
||||
if (!isset($input['user'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $user when calling testBodyWithQueryParams');
|
||||
}
|
||||
$user = $input['user'];
|
||||
|
||||
|
||||
return response('How about implementing testBodyWithQueryParams as a put method ?');
|
||||
}
|
||||
/**
|
||||
* Operation testInlineAdditionalProperties
|
||||
*
|
||||
* test inline additionalProperties.
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function testInlineAdditionalProperties()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
if (!isset($input['request_body'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $request_body when calling testInlineAdditionalProperties');
|
||||
}
|
||||
$request_body = $input['request_body'];
|
||||
|
||||
|
||||
return response('How about implementing testInlineAdditionalProperties as a post method ?');
|
||||
}
|
||||
/**
|
||||
* Operation testJsonFormData
|
||||
*
|
||||
* test json serialization of form data.
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function testJsonFormData()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
if (!isset($input['param'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $param when calling testJsonFormData');
|
||||
}
|
||||
$param = $input['param'];
|
||||
|
||||
if (!isset($input['param2'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $param2 when calling testJsonFormData');
|
||||
}
|
||||
$param2 = $input['param2'];
|
||||
|
||||
|
||||
return response('How about implementing testJsonFormData as a get method ?');
|
||||
}
|
||||
/**
|
||||
* Operation fakeOuterBooleanSerialize
|
||||
*
|
||||
* .
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function fakeOuterBooleanSerialize()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
$body = $input['body'];
|
||||
|
||||
|
||||
return response('How about implementing fakeOuterBooleanSerialize as a post method ?');
|
||||
}
|
||||
/**
|
||||
* Operation fakeOuterCompositeSerialize
|
||||
*
|
||||
* .
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function fakeOuterCompositeSerialize()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
$outer_composite = $input['outer_composite'];
|
||||
|
||||
|
||||
return response('How about implementing fakeOuterCompositeSerialize as a post method ?');
|
||||
}
|
||||
/**
|
||||
* Operation fakeOuterNumberSerialize
|
||||
*
|
||||
* .
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function fakeOuterNumberSerialize()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
$body = $input['body'];
|
||||
|
||||
|
||||
return response('How about implementing fakeOuterNumberSerialize as a post method ?');
|
||||
}
|
||||
/**
|
||||
* Operation fakeOuterStringSerialize
|
||||
*
|
||||
* .
|
||||
*
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function fakeOuterStringSerialize()
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
$body = $input['body'];
|
||||
|
||||
|
||||
return response('How about implementing fakeOuterStringSerialize as a post method ?');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* OpenAPI 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Source files are located at:
|
||||
*
|
||||
* > swagger-codegen/modules/swagger-codegen/src/main/resources/php-laravel/
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
class PetController extends Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation uploadFileWithRequiredFile
|
||||
*
|
||||
* uploads an image (required).
|
||||
*
|
||||
* @param int $pet_id ID of pet to update (required)
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function uploadFileWithRequiredFile($pet_id)
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
|
||||
return response('How about implementing uploadFileWithRequiredFile as a post method ?');
|
||||
}
|
||||
/**
|
||||
* 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['pet'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $pet when calling addPet');
|
||||
}
|
||||
$pet = $input['pet'];
|
||||
|
||||
|
||||
return response('How about implementing addPet as a post 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['pet'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $pet when calling updatePet');
|
||||
}
|
||||
$pet = $input['pet'];
|
||||
|
||||
|
||||
return response('How about implementing updatePet as a put 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 deletePet
|
||||
*
|
||||
* Deletes a pet.
|
||||
*
|
||||
* @param int $pet_id Pet id to delete (required)
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function deletePet($pet_id)
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
|
||||
return response('How about implementing deletePet as a delete method ?');
|
||||
}
|
||||
/**
|
||||
* Operation getPetById
|
||||
*
|
||||
* Find pet by ID.
|
||||
*
|
||||
* @param int $pet_id ID of pet to return (required)
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function getPetById($pet_id)
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
|
||||
return response('How about implementing getPetById as a get method ?');
|
||||
}
|
||||
/**
|
||||
* Operation updatePetWithForm
|
||||
*
|
||||
* Updates a pet in the store with form data.
|
||||
*
|
||||
* @param int $pet_id ID of pet that needs to be updated (required)
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function updatePetWithForm($pet_id)
|
||||
{
|
||||
$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 int $pet_id ID of pet to update (required)
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function uploadFile($pet_id)
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
|
||||
return response('How about implementing uploadFile as a post method ?');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* OpenAPI 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Source files are located at:
|
||||
*
|
||||
* > swagger-codegen/modules/swagger-codegen/src/main/resources/php-laravel/
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
class StoreController extends Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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['order'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $order when calling placeOrder');
|
||||
}
|
||||
$order = $input['order'];
|
||||
|
||||
|
||||
return response('How about implementing placeOrder as a post method ?');
|
||||
}
|
||||
/**
|
||||
* Operation deleteOrder
|
||||
*
|
||||
* Delete purchase order by ID.
|
||||
*
|
||||
* @param string $order_id ID of the order that needs to be deleted (required)
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function deleteOrder($order_id)
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
|
||||
|
||||
//not path params validation
|
||||
|
||||
return response('How about implementing deleteOrder as a delete method ?');
|
||||
}
|
||||
/**
|
||||
* Operation getOrderById
|
||||
*
|
||||
* Find purchase order by ID.
|
||||
*
|
||||
* @param int $order_id ID of pet that needs to be fetched (required)
|
||||
*
|
||||
* @return Http response
|
||||
*/
|
||||
public function getOrderById($order_id)
|
||||
{
|
||||
$input = Request::all();
|
||||
|
||||
//path params validation
|
||||
if ($order_id > 5) {
|
||||
throw new \InvalidArgumentException('invalid value for $order_id when calling StoreController.getOrderById, must be smaller than or equal to 5.');
|
||||
}
|
||||
if ($order_id < 1) {
|
||||
throw new \InvalidArgumentException('invalid value for $order_id when calling StoreController.getOrderById, must be bigger than or equal to 1.');
|
||||
}
|
||||
|
||||
|
||||
//not path params validation
|
||||
|
||||
return response('How about implementing getOrderById as a get method ?');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* OpenAPI 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
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Source files are located at:
|
||||
*
|
||||
* > swagger-codegen/modules/swagger-codegen/src/main/resources/php-laravel/
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
class UserController 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['user'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $user when calling createUser');
|
||||
}
|
||||
$user = $input['user'];
|
||||
|
||||
|
||||
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['user'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $user when calling createUsersWithArrayInput');
|
||||
}
|
||||
$user = $input['user'];
|
||||
|
||||
|
||||
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['user'])) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter $user when calling createUsersWithListInput');
|
||||
}
|
||||
$user = $input['user'];
|
||||
|
||||
|
||||
return response('How about implementing createUsersWithListInput as a post 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 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 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 ?');
|
||||
}
|
||||
}
|
||||
63
samples/server/petstore/php-laravel/lib/app/Http/Kernel.php
Normal file
63
samples/server/petstore/php-laravel/lib/app/Http/Kernel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:60,1',
|
||||
'bindings',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user