-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5c507a8
Showing
10 changed files
with
487 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Convention.php-docs | ||
|
||
on: push | ||
|
||
jobs: | ||
cd: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: cd | ||
uses: tripteki/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
repotoken: ${{ secrets.REPOSITORY_TOKEN }} | ||
repouser: tripteki | ||
repository: https://packagist.org | ||
language: php | ||
artifact: composer.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Trip Teknologi | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<h1 align="center">Convention</h1> | ||
|
||
Trip Teknologi's Codebase Convention. | ||
|
||
Getting Started | ||
--- | ||
|
||
Installation : | ||
|
||
``` | ||
$ composer require tripteki/laravelphp-docs | ||
``` | ||
|
||
How to use : | ||
|
||
- Put `Tripteki\Docs\Providers\DocsServiceProvider::ignoreConfig()` into `register` provider, then publish config file into your project's directory with running (optionally) : | ||
|
||
``` | ||
php artisan vendor:publish --tag=tripteki-laravelphp-docs-config | ||
``` | ||
|
||
- Put the comment onto the `App\Http\Controllers\Controller` : | ||
|
||
``` | ||
/** | ||
* @OA\Info( | ||
* title="Application Programming Interface", | ||
* version="1.0" | ||
* ), | ||
* @OA\SecurityScheme( | ||
* securityScheme="bearerAuth", | ||
* in="header", | ||
* type="http", | ||
* scheme="bearer", | ||
* bearerFormat="JWT" | ||
* ) | ||
*/ | ||
``` | ||
|
||
Usage | ||
--- | ||
|
||
`php artisan swagger:generate` | ||
|
||
Author | ||
--- | ||
|
||
- Trip Teknologi ([@tripteki](https://linkedin.com/company/tripteki)) | ||
- Hasby Maulana ([@hsbmaulana](https://linkedin.com/in/hsbmaulana)) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "tripteki/laravelphp-docs", | ||
"version": "1.0.0", | ||
"description": "Trip Teknologi's Codebase Convention", | ||
|
||
"readme": "README.md", | ||
"license": "MIT", | ||
"authors": [ { "name": "Trip Teknologi", "email": "[email protected]" } ], | ||
"homepage": "https://github.com/tripteki/convention-php-docs", | ||
"support": { "issues": "https://github.com/tripteki/convention-php-docs/issues" }, | ||
|
||
"require": { | ||
|
||
"php": "^8.0.2", | ||
|
||
"darkaonline/l5-swagger": "^8.4.1" | ||
}, | ||
|
||
"require-dev": {}, | ||
|
||
"autoload": { | ||
|
||
"psr-4": { | ||
|
||
"Tripteki\\Docs\\": "src/" | ||
} | ||
}, | ||
|
||
"autoload-dev": {}, | ||
|
||
"extra": { | ||
|
||
"laravel": { | ||
|
||
"dont-discover": [], | ||
|
||
"providers": [ | ||
|
||
"Tripteki\\Docs\\Providers\\DocsServiceProvider" | ||
], | ||
|
||
"aliases": [] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
"default" => env("SWAGGER", "default"), | ||
|
||
"documentations" => [ | ||
|
||
"default" => [ | ||
|
||
"api" => [ "title" => "Swagger", ], | ||
|
||
"routes" => [ | ||
|
||
"api" => "api/documentation", | ||
], | ||
|
||
"paths" => [ | ||
|
||
"use_absolute_path" => true, | ||
|
||
"docs_json" => "default.json", | ||
"docs_yaml" => "default.yaml", | ||
|
||
"format_to_use_for_docs" => env("SWAGGER_DEFAULT_FORMAT", "json"), | ||
|
||
"annotations" => [ | ||
|
||
base_path("app"), | ||
base_path("src"), | ||
], | ||
], | ||
], | ||
], | ||
|
||
|
||
|
||
"defaults" => [ | ||
|
||
"generate_always" => false, | ||
"generate_yaml_copy" => false, | ||
|
||
"additional_config_url" => null, | ||
|
||
"operations_sort" => null, | ||
|
||
"validator_url" => null, | ||
|
||
"proxy" => false, | ||
|
||
"ui" => [ | ||
|
||
"display" => [ | ||
|
||
"filter" => true, | ||
|
||
"doc_expansion" => "none", | ||
], | ||
|
||
"authorization" => [ | ||
|
||
"persist_authorization" => false, | ||
|
||
"oauth2" => [ | ||
|
||
"use_pkce_with_authorization_code_grant" => false, | ||
], | ||
], | ||
], | ||
|
||
"routes" => [ | ||
|
||
"docs" => "/", | ||
|
||
"oauth2_callback" => "api/oauth2-callback", | ||
|
||
"middleware" => [ | ||
|
||
"asset" => [], | ||
"api" => [], | ||
"docs" => [], | ||
"oauth2_callback" => [], | ||
], | ||
|
||
"group_options" => [], | ||
], | ||
|
||
"paths" => [ | ||
|
||
"docs" => storage_path("swagger"), | ||
|
||
"views" => resource_path("views/vendor/swagger"), | ||
|
||
"base" => "api", | ||
|
||
"swagger_ui_assets_path" => "vendor/swagger-api/swagger-ui/dist", | ||
|
||
"excludes" => [], | ||
], | ||
|
||
"scanOptions" => [ | ||
|
||
"analyser" => null, | ||
"analysis" => null, | ||
|
||
"processors" => [], | ||
|
||
"pattern" => null, | ||
|
||
"exclude" => [], | ||
|
||
"open_api_spec_version" => \L5Swagger\Generator::OPEN_API_DEFAULT_SPEC_VERSION, | ||
], | ||
|
||
"securityDefinitions" => [ | ||
|
||
"securitySchemes" => [], | ||
|
||
"security" => [], | ||
], | ||
|
||
"constants" => [ | ||
|
||
"SWAGGER_PREFIX" => env("SWAGGER_PREFIX", "/api"), | ||
], | ||
], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>{{ config('l5-swagger.documentations.'.$documentation.'.api.title') }}</title> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/png" href="{{ l5_swagger_asset($documentation, 'favicon-32x32.png') }}" sizes="32x32" /> | ||
<link rel="icon" type="image/png" href="{{ l5_swagger_asset($documentation, 'favicon-16x16.png') }}" sizes="16x16" /> | ||
<link rel="stylesheet" type="text/css" href="{{ l5_swagger_asset($documentation, 'swagger-ui.css') }}" /> | ||
<style type="text/css"> | ||
html | ||
{ | ||
box-sizing: border-box; | ||
overflow: -moz-scrollbars-vertical; | ||
overflow-y: scroll; | ||
} | ||
*, *:before, *:after | ||
{ | ||
box-sizing: inherit; | ||
} | ||
body | ||
{ | ||
margin: 0; | ||
background: #fafafa; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="swagger"></div> | ||
|
||
<script type="text/javascript" src="{{ l5_swagger_asset($documentation, 'swagger-ui-bundle.js') }}"></script> | ||
<script type="text/javascript" src="{{ l5_swagger_asset($documentation, 'swagger-ui-standalone-preset.js') }}"></script> | ||
<script type="text/javascript"> | ||
window.onload = function () | ||
{ | ||
const swagger = SwaggerUIBundle( | ||
{ | ||
dom_id: "#swagger", | ||
url: "{!! $urlToDocs !!}", | ||
operationsSorter: {!! isset($operationsSorter) ? '"'.$operationsSorter.'"' : 'null' !!}, | ||
configUrl: {!! isset($configUrl) ? '"'.$configUrl.'"' : 'null' !!}, | ||
validatorUrl: {!! isset($validatorUrl) ? '"'.$validatorUrl.'"' : 'null' !!}, | ||
oauth2RedirectUrl: "{{ route('l5-swagger.'.$documentation.'.oauth2_callback', [], $useAbsolutePath) }}", | ||
layout: "StandaloneLayout", | ||
docExpansion : "{!! config('l5-swagger.defaults.ui.display.doc_expansion', 'none') !!}", | ||
deepLinking: true, | ||
filter: {!! config('l5-swagger.defaults.ui.display.filter') ? 'true' : 'false' !!}, | ||
persistAuthorization: "{!! config('l5-swagger.defaults.ui.authorization.persist_authorization') ? 'true' : 'false' !!}", | ||
requestInterceptor: function (request) { | ||
request.headers['X-CSRF-TOKEN'] = '{{ csrf_token() }}'; | ||
return request; | ||
}, | ||
presets: [ | ||
SwaggerUIBundle.presets.apis, | ||
SwaggerUIStandalonePreset, | ||
], | ||
plugins: [ | ||
SwaggerUIBundle.plugins.DownloadUrl, | ||
], | ||
}); | ||
window.swagger = swagger; | ||
@if(in_array("oauth2", array_column(config("l5-swagger.defaults.securityDefinitions.securitySchemes"), "type"))) | ||
swagger.initOAuth( | ||
{ | ||
usePkceWithAuthorizationCodeGrant: "{!! (bool) config('l5-swagger.defaults.ui.authorization.oauth2.use_pkce_with_authorization_code_grant') !!}", | ||
}); | ||
@endif | ||
}; | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Tripteki\Docs\Console\Commands; | ||
|
||
use L5Swagger\Console\GenerateDocsCommand as Command; | ||
|
||
class GenerateDocsCommand extends Command | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $signature = "swagger:generate {documentation?} {--all}"; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $description = "Regenerate swagger docs"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Tripteki\Docs\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class UnGenerateDocsCommand extends Command | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
protected $hidden = true; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $signature = "l5-swagger:generate {documentation?} {--all}"; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $description = "Regenerate swagger docs"; | ||
}; |
Oops, something went wrong.