├── .github ├── FUNDING.yml └── workflows │ └── run-tests.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json ├── composer.lock ├── config └── stoplight.php ├── resources └── views │ └── docs.blade.php ├── routes └── stoplight.php └── src └── StoplightServiceProvider.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [JustSteveKing] -------------------------------------------------------------------------------- /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | name: run-tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | test: 13 | runs-on: ${{ matrix.os }} 14 | 15 | strategy: 16 | fail-fast: true 17 | matrix: 18 | os: [ubuntu-latest, windows-latest] 19 | php: [7.4, 8.0, '8.2', '8.3', '8.4'] 20 | laravel: ['8.*', '12.*'] 21 | stability: [prefer-lowest, prefer-stable] 22 | include: 23 | - laravel: 8.* 24 | testbench: ^6.6 25 | - laravel: 12.* 26 | testbench: ^10.0 27 | exclude: 28 | - laravel: 12.* 29 | php: 7.4 30 | - laravel: 12.* 31 | php: 8.0 32 | 33 | name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} 34 | 35 | steps: 36 | - name: Checkout code 37 | uses: actions/checkout@v2 38 | 39 | - name: Setup PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: ${{ matrix.php }} 43 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo 44 | coverage: none 45 | 46 | - name: Setup problem matchers 47 | run: | 48 | echo "::add-matcher::${{ runner.tool_cache }}/php.json" 49 | echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" 50 | 51 | - name: Install dependencies 52 | run: | 53 | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update 54 | composer update --${{ matrix.stability }} --prefer-dist --no-interaction 55 | 56 | - name: Execute tests 57 | run: vendor/bin/phpunit --testdox 58 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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**! -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Stoplight Elements 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-stoplight-elements 16 | ``` 17 | 18 | 19 | ## Configuration 20 | 21 | You can publish the configuration file with: 22 | 23 | ```bash 24 | php artisan vendor:publish --provider="JustSteveKing\Laravel\LaravelStoplight\StoplightServiceProvider" --tag="config" 25 | ``` 26 | 27 | This is the contents of the published config file: 28 | 29 | ```php 30 | return [ 31 | 'title' => 'API Documentation', 32 | 'path' => [ 33 | 'name' => env('STOPLIGHT_PATH_NAME', 'docs'), 34 | 'url' => env('STOPLIGHT_PATH_URL', 'api/docs'), 35 | ], 36 | 37 | 'openapi' => [ 38 | 'path' => env('STOPLIGHT_OPENAPI_PATH', 'https://api.apis.guru/v2/specs/github.com/1.1.4/openapi.yaml') 39 | ], 40 | 41 | 'config' => [ 42 | 'router' => "hash", 43 | 44 | 'layout' => "sidebar", 45 | ] 46 | ]; 47 | ``` 48 | 49 | 50 | ## Contributing 51 | 52 | Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details. 53 | 54 | 55 | ## Security 56 | 57 | If you discover any security related issues, please email juststevemcd@gmail.com instead of using the issue tracker. 58 | 59 | 60 | ## Credits 61 | 62 | - [Steve McDougall][link-author] 63 | - [All Contributors][link-contributors] 64 | - [Stoplight Team for the Elements Web Components](https://stoplight.io/open-source/elements/) 65 | 66 | 67 | ## License 68 | 69 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 70 | 71 | 72 | [ico-version]: https://img.shields.io/packagist/v/juststeveking/laravel-stoplight-elements.svg?style=flat-square 73 | [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square 74 | [ico-github-action]: https://github.com/JustSteveKing/laravel-stoplight-elements/workflows/run-tests/badge.svg?branch=main 75 | [ico-downloads]: https://img.shields.io/packagist/dt/juststeveking/laravel-stoplight-elements.svg?style=flat-square 76 | 77 | [link-packagist]: https://packagist.org/packages/juststeveking/laravel-stoplight-elements 78 | [link-github-action]: https://github.com/JustSteveKing/laravel-stoplight-elements/actions 79 | [link-downloads]: https://packagist.org/packages/juststeveking/laravel-stoplight-elements 80 | [link-author]: https://github.com/JustSteveKing 81 | [link-contributors]: ../../contributors 82 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "juststeveking/laravel-stoplight-elements", 3 | "description": "A simple API documentation package for Laravel using OpenAPI and Stoplight Elements", 4 | "keywords": [ 5 | "laravel", 6 | "api", 7 | "documentation", 8 | "stoplight", 9 | "stoplight elements", 10 | "openapi" 11 | ], 12 | "type": "library", 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "role": "developer", 17 | "name": "Steve McDougall", 18 | "email": "juststevemcd@gmail.com", 19 | "homepage": "https://www.juststeveking.uk/" 20 | } 21 | ], 22 | "minimum-stability": "dev", 23 | "prefer-stable": true, 24 | "config": { 25 | "sort-packages": true, 26 | "preferred-install": "dist", 27 | "optimize-autoloader": true 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "JustSteveKing\\Laravel\\LaravelStoplight\\": "src/" 32 | } 33 | }, 34 | "autoload-dev": { 35 | "psr-4": { 36 | "JustSteveKing\\Laravel\\LaravelStoplight\\Tests\\": "tests/" 37 | } 38 | }, 39 | "require": { 40 | "php": "^7.4|^8.0|^8.1|^8.2|^8.3", 41 | "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0" 42 | }, 43 | "require-dev": { 44 | "orchestra/testbench": "^9|^10.0", 45 | "phpunit/phpunit": "^10|^11.5.3" 46 | }, 47 | "extra": { 48 | "laravel": { 49 | "providers": [ 50 | "JustSteveKing\\Laravel\\LaravelStoplight\\StoplightServiceProvider" 51 | ] 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /config/stoplight.php: -------------------------------------------------------------------------------- 1 | 'API Documentation', 13 | 14 | /* 15 | |-------------------------------------------------------------------------- 16 | | Stoplight Route 17 | |-------------------------------------------------------------------------- 18 | | 19 | | Customise the name and url of where your API documentation will respond. 20 | | 21 | */ 22 | 'path' => [ 23 | 'name' => env('STOPLIGHT_PATH_NAME', 'docs'), 24 | 'url' => env('STOPLIGHT_PATH_URL', 'api/docs'), 25 | ], 26 | 27 | /* 28 | |-------------------------------------------------------------------------- 29 | | OpenAPI Specification 30 | |-------------------------------------------------------------------------- 31 | | 32 | | Provide a link to your local or cloud based open api specification. 33 | | 34 | */ 35 | 'openapi' => [ 36 | 'path' => env('STOPLIGHT_OPENAPI_PATH', 'https://api.apis.guru/v2/specs/github.com/1.1.4/openapi.yaml') 37 | ], 38 | 39 | 'config' => [ 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Router Mode 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Determines how navigation should work. 46 | | 47 | | Supported: "hash", "history", "memory" 48 | | 49 | | Hash: Uses the hash portion of the URL (i.e. window.location.hash) to keep the UI in sync with the URL. 50 | | History: Uses the HTML5 history API to keep the UI in sync with the URL. 51 | | Memory: Keeps the history of your “URL” in memory (does not read or write to the address bar) 52 | | 53 | */ 54 | 'router' => "hash", 55 | 56 | /* 57 | |-------------------------------------------------------------------------- 58 | | Layout 59 | |-------------------------------------------------------------------------- 60 | | 61 | | There are two layouts for Elements. 62 | | 63 | | Supported: "sidebar", "stacked" 64 | | 65 | | Sidebar: Three-column design. 66 | | Stacked: Everything in a single column, making integrations with 67 | | existing websites that have their own sidebar or other columns already. 68 | | 69 | */ 70 | 'layout' => "sidebar", 71 | ] 72 | ]; 73 | -------------------------------------------------------------------------------- /resources/views/docs.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ config('stoplight.title') }} 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /routes/stoplight.php: -------------------------------------------------------------------------------- 1 | name( 9 | config('stoplight.path.name') 10 | ); 11 | -------------------------------------------------------------------------------- /src/StoplightServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->runningInConsole()) { 14 | // Publish Config 15 | $this->publishes([ 16 | __DIR__ . '/../config/stoplight.php' => config_path('stoplight.php'), 17 | ], 'config'); 18 | 19 | // Publish Views 20 | $this->publishes([ 21 | __DIR__ . '/../resources/views' => base_path('resources/views/vendor/stoplight'), 22 | ], 'views'); 23 | } 24 | 25 | $this->loadRoutesFrom( 26 | __DIR__ . '/../routes/stoplight.php' 27 | ); 28 | 29 | $this->loadViewsFrom( 30 | __DIR__ . '/../resources/views', 31 | 'stoplight', 32 | ); 33 | } 34 | 35 | public function register() 36 | { 37 | $this->mergeConfigFrom( 38 | __DIR__ . '/../config/stoplight.php', 39 | 'stoplight', 40 | ); 41 | } 42 | } 43 | --------------------------------------------------------------------------------