├── .github ├── FUNDING.yml └── workflows │ └── run-tests.yml ├── routes └── redoc.php ├── src └── RedocServiceProvider.php ├── LICENSE.md ├── CONTRIBUTING.md ├── composer.json ├── resources └── views │ └── docs.blade.php ├── README.md ├── CODE_OF_CONDUCT.md └── config └── redoc.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [JustSteveKing] -------------------------------------------------------------------------------- /routes/redoc.php: -------------------------------------------------------------------------------- 1 | name( 9 | config('redoc.path.name') 10 | )->middleware( 11 | config('redoc.path.middleware', []) 12 | ); 13 | -------------------------------------------------------------------------------- /src/RedocServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->runningInConsole()) { 14 | // Publish Config 15 | $this->publishes([ 16 | __DIR__ . '/../config/redoc.php' => config_path('redoc.php'), 17 | ], 'config'); 18 | 19 | // Publish Views 20 | $this->publishes([ 21 | __DIR__ . '/../resources/views' => base_path('resources/views/vendor/redoc'), 22 | ], 'views'); 23 | } 24 | 25 | $this->loadRoutesFrom( 26 | __DIR__ . '/../routes/redoc.php' 27 | ); 28 | 29 | $this->loadViewsFrom( 30 | __DIR__ . '/../resources/views', 31 | 'redoc', 32 | ); 33 | } 34 | 35 | public function register() 36 | { 37 | $this->mergeConfigFrom( 38 | __DIR__ . '/../config/redoc.php', 39 | 'redoc', 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Steve McDougall 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/JustSteveKing/LaravelPostcodes). 6 | 7 | 8 | ## Pull Requests 9 | 10 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - Check the code style with ``$ composer check-style`` and fix it with ``$ composer fix-style``. 11 | 12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 13 | 14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 15 | 16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 17 | 18 | - **Create feature branches** - Don't ask us to pull from your master branch. 19 | 20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 21 | 22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 23 | 24 | 25 | **Happy coding**! -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "juststeveking/laravel-redoc", 3 | "description": "A simple API documentation package for Laravel using OpenAPI and Redoc", 4 | "keywords": [ 5 | "laravel", 6 | "api", 7 | "documentation", 8 | "redoc", 9 | "openapi" 10 | ], 11 | "type": "library", 12 | "license": "MIT", 13 | "authors": [ 14 | { 15 | "role": "developer", 16 | "name": "Steve McDougall", 17 | "email": "juststevemcd@gmail.com", 18 | "homepage": "https://www.juststeveking.uk/" 19 | } 20 | ], 21 | "minimum-stability": "dev", 22 | "prefer-stable": true, 23 | "config": { 24 | "sort-packages": true, 25 | "preferred-install": "dist", 26 | "optimize-autoloader": true 27 | }, 28 | "autoload": { 29 | "psr-4": { 30 | "JustSteveKing\\Laravel\\LaravelRedoc\\": "src/" 31 | } 32 | }, 33 | "autoload-dev": { 34 | "psr-4": { 35 | "JustSteveKing\\Laravel\\LaravelRedoc\\Tests\\": "tests/" 36 | } 37 | }, 38 | "require": { 39 | "php": "^8.0", 40 | "illuminate/support": "^10.0|^11.0" 41 | }, 42 | "require-dev": { 43 | "orchestra/testbench": "^8.0", 44 | "phpunit/phpunit": "^9.5" 45 | }, 46 | "extra": { 47 | "laravel": { 48 | "providers": [ 49 | "JustSteveKing\\Laravel\\LaravelRedoc\\RedocServiceProvider" 50 | ] 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | name: run-tests 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | test: 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | fail-fast: true 15 | matrix: 16 | os: [ubuntu-latest, windows-latest] 17 | php: [8.2] 18 | stability: [prefer-lowest, prefer-stable] 19 | include: 20 | - laravel: 10.* 21 | testbench: ^8.* 22 | 23 | - laravel: 11.* 24 | testbench: ^8.* 25 | 26 | name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} 27 | 28 | steps: 29 | - name: Checkout code 30 | uses: actions/checkout@v2 31 | 32 | - name: Setup PHP 33 | uses: shivammathur/setup-php@v2 34 | with: 35 | php-version: ${{ matrix.php }} 36 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo 37 | coverage: none 38 | 39 | - name: Setup problem matchers 40 | run: | 41 | echo "::add-matcher::${{ runner.tool_cache }}/php.json" 42 | echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" 43 | 44 | - name: Install dependencies 45 | run: | 46 | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update 47 | composer update --${{ matrix.stability }} --prefer-dist --no-interaction 48 | 49 | - name: Execute tests 50 | run: vendor/bin/phpunit --testdox 51 | -------------------------------------------------------------------------------- /resources/views/docs.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{ config('redoc.config.title') }} 12 | 13 | 14 | 20 | 21 | 22 | 31 | 32 | @if (config('redoc.alfred.enabled')) 33 |
38 | 39 | @endif 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Redoc 2 | 3 | [![Latest Version on Packagist][ico-version]][link-packagist] 4 | [![Software License][ico-license]](LICENSE.md) 5 | [![Build Status][ico-github-action]][link-github-action] 6 | [![Total Downloads][ico-downloads]][link-downloads] 7 | 8 | Easily publish your API documentation using your OpenAPI document in your Laravel Application. 9 | 10 | ## Installation 11 | 12 | You can install this package via composer: 13 | 14 | ```bash 15 | composer require juststeveking/laravel-redoc 16 | ``` 17 | 18 | ## Enabling Alfred 19 | 20 | To enable Alfred on your docs, visit: https://www.treblle.com/product/alfred or https://docs.treblle.com/treblle/ai-assistant 21 | 22 | ## Configuration 23 | 24 | You can publish the configuration file with: 25 | 26 | ```bash 27 | php artisan vendor:publish --provider="JustSteveKing\Laravel\LaravelRedoc\RedocServiceProvider" --tag="config" 28 | ``` 29 | 30 | This is the contents of the published config file: 31 | 32 | ```php 33 | return [ 34 | 'path' => [ 35 | 'name' => env('REDOC_PATH_NAME', 'docs'), 36 | 'url' => env('REDOC_PATH_URL', 'api/docs'), 37 | ], 38 | 39 | 'alfred' => [ 40 | 'enabled' => env('REDOC_ALFRED', true), 41 | 'project_id' => env('ALFRED_PROJECT_ID', null), 42 | 'api_key' => env('ALFRED_API_KEY', null), 43 | ], 44 | 45 | 'openapi' => [ 46 | 'path' => env('REDOC_OPENAPI_PATH', 'http://petstore.swagger.io/v2/swagger.json') 47 | ], 48 | 49 | 'config' => [ 50 | 'search' => false, 51 | 52 | 'hostname' => false, 53 | 54 | 'loading' => false, 55 | 56 | 'menu' => true, 57 | 58 | 'scrollbars' => true, 59 | 60 | 'trust' => true, 61 | ] 62 | ]; 63 | ``` 64 | 65 | 66 | ## Contributing 67 | 68 | Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details. 69 | 70 | 71 | ## Security 72 | 73 | If you discover any security related issues, please email juststevemcd@gmail.com instead of using the issue tracker. 74 | 75 | 76 | ## Credits 77 | 78 | - [Steve McDougall][link-author] 79 | - [All Contributors][link-contributors] 80 | - [Redocly Team for their open source tool redoc](https://github.com/Redocly/redoc) 81 | 82 | 83 | ## License 84 | 85 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 86 | 87 | [ico-version]: https://img.shields.io/packagist/v/juststeveking/laravel-redoc.svg?style=flat-square 88 | [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square 89 | [ico-github-action]: https://github.com/JustSteveKing/laravel-redoc/workflows/run-tests/badge.svg?branch=main 90 | [ico-downloads]: https://img.shields.io/packagist/dt/juststeveking/laravel-redoc.svg?style=flat-square 91 | 92 | [link-packagist]: https://packagist.org/packages/juststeveking/laravel-redoc 93 | [link-github-action]: https://github.com/JustSteveKing/laravel-redoc/actions 94 | [link-downloads]: https://packagist.org/packages/juststeveking/laravel-redoc 95 | [link-author]: https://github.com/JustSteveKing 96 | [link-contributors]: ../../contributors -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to make participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at `juststevemcd@gmail.com`. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /config/redoc.php: -------------------------------------------------------------------------------- 1 | [ 13 | 'name' => env('REDOC_PATH_NAME', 'docs'), 14 | 'url' => env('REDOC_PATH_URL', 'api/docs'), 15 | 'middleware' => [ 16 | //\App\Http\Middleware\BasicAuthentication::class, 17 | ], 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Alfred Support 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Enable Alfred Support 26 | | @see https://docs.treblle.com/treblle/ai-assistant/ 27 | | 28 | */ 29 | 'alfred' => [ 30 | 'enabled' => env('REDOC_ALFRED', true), 31 | 'project_id' => env('ALFRED_PROJECT_ID', null), 32 | 'api_key' => env('ALFRED_API_KEY', null), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | OpenAPI Specification 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Provide a link to your local or cloud based open api specification. 41 | | 42 | */ 43 | 'openapi' => [ 44 | 'path' => env('REDOC_OPENAPI_PATH', 'http://petstore.swagger.io/v2/swagger.json') 45 | ], 46 | 47 | 'config' => [ 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Title 51 | |-------------------------------------------------------------------------- 52 | | 53 | | Customize the html title of your API documentation 54 | | 55 | */ 56 | 'title' => env('REDOC_TITLE', 'ReDoc'), 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | Disable Search 61 | |-------------------------------------------------------------------------- 62 | | 63 | | Disable search indexing and search box. 64 | | 65 | | Supported: "true", "false" 66 | | 67 | */ 68 | 'search' => false, 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Hide Hostname 73 | |-------------------------------------------------------------------------- 74 | | 75 | | If set, the protocol and hostname is not shown in the operation definition. 76 | | 77 | | Supported: "true", "false" 78 | | 79 | */ 80 | 'hostname' => false, 81 | 82 | /* 83 | |-------------------------------------------------------------------------- 84 | | Hide Loading 85 | |-------------------------------------------------------------------------- 86 | | 87 | | Do not show loading animation. Useful for small docs. 88 | | 89 | | Supported: "true", "false" 90 | | 91 | */ 92 | 'loading' => false, 93 | 94 | /* 95 | |-------------------------------------------------------------------------- 96 | | Menu Toggle 97 | |-------------------------------------------------------------------------- 98 | | 99 | | If true clicking second time on expanded menu item will collapse it. 100 | | 101 | | Default: true 102 | | 103 | | Supported: "true", "false" 104 | | 105 | */ 106 | 'menu' => true, 107 | 108 | /* 109 | |-------------------------------------------------------------------------- 110 | | Native Scrollbars 111 | |-------------------------------------------------------------------------- 112 | | 113 | | Use native scrollbar for sidemenu instead of perfect-scroll 114 | | (scrolling performance optimization for big specs). 115 | | 116 | | Supported: "true", "false" 117 | | 118 | */ 119 | 'scrollbars' => true, 120 | 121 | /* 122 | |-------------------------------------------------------------------------- 123 | | Untrusted Spec 124 | |-------------------------------------------------------------------------- 125 | | 126 | | if set, the spec is considered untrusted and all HTML/markdown 127 | | is sanitized to prevent XSS. Disabled by default for performance reasons. 128 | | Enable this option if you work with untrusted user data! 129 | | 130 | | Supported: "true", "false" 131 | | 132 | */ 133 | 'trust' => true, 134 | ] 135 | ]; 136 | --------------------------------------------------------------------------------