A simple API documentation package for Laravel using OpenAPI and Redoc

Overview

Laravel Redoc

Latest Version on Packagist Software License Build Status Total Downloads

Easily publish your API documentation using your OpenAPI document in your Laravel Application.

Installation

You can install this package via composer:

composer require juststeveking/laravel-redoc

Configuration

You can publish the configuration file with:

php artisan vendor:publish --provider="JustSteveKing\Laravel\LaravelRedoc\RedocServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    'path' => [
        'name' => env('REDOC_PATH_NAME', 'docs'),
        'url' => env('REDOC_PATH_URL', 'api/docs'),
    ],

    'openapi' => [
        'path' => env('REDOC_OPENAPI_PATH', 'http://petstore.swagger.io/v2/swagger.json')
    ],

    'config' => [
        'search' => false,

        'hostname' => false,

        'loading' => false,

        'menu' => true,

        'scrollbars' => true,

        'trust' => true,
    ]
];

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Multi-File OpenAPI specs?

    Multi-File OpenAPI specs?

    Hi, thanks for creating this package. Our API is spec'd out using multiple OpenAPI files (Redoc seems to recommend this approach as well). I didn't see a way to configure that in the config, as it doesn't accept folder, but requires pointing to a OpenAPI spec file directly.

    Thanks for your help, would love to be able to use your package!

    opened by mikebronner 2
  • Feature - Route Middleware

    Feature - Route Middleware

    Problem - Redoc route is public and unprotected

    Solution - Optional middleware in route configuration, user can specify which middleware the route is covered by, fallback to empty array if middleware config is missing for backwards compatibility with older configs.

    opened by johnathanmdell 1
  • Config Setting Oddity

    Config Setting Oddity

    For some reason the hostname setting only shows the hostname when set to false (boolean), but hides the hostname when set to "false" (string) as the comments suggest to use. All other config variables work with stringified booleans, which is very confusing. I just wanted to bring this up as an issue, instead of assuming how you want this fixed.

    I'm happy to open a PR to bring the config values more inline with what a Laravel develop might expect, if that is something that would help you out. (For example, all the config values are inverted in their meaning, as in hostname should actually be hideHostname and be a true boolean, then handle it accordingly in the blade view to meet the redoc requirements. Just a suggestion.)

    Thanks! :)

    opened by mikebronner 1
  • Fix enabling/disabling of search functionality.

    Fix enabling/disabling of search functionality.

    Problem

    With the latest version of redoc 2x alpha it appears that whenever the attribute disable-search is added to the redoc tag, regardless of the value it is set to, search is disabled.

    Solution

    To fix this, we can conditionally render the disable-search attribute only for when it is needed.

    opened by mikebronner 1
  • UI Questions

    UI Questions

    Hi @JustSteveKing, we have successfully implemented our OpenAPI spec file now, and I have a few questions that I'm not sure how to address, if you don't mind?

    1. ~~Is there a way to customize the theme, say add a logo, customize colors, etc?~~
    2. ~~The search functionality doesn't seem to be working, as the search field doesn't show even if I change the config setting.~~
    3. ~~Long examples don't seem to wrap nicely, and get obscured behind the right sidebar. This may be addressable by editing the theme, per question # 1.~~
    4. ~~is automatic doc generation something that might be on the roadmap? Not required, just curios.~~

    I really like you package, as it lets me create my docs using the spotlight.io GUI, and push them to my repo, and your package automatically renders it. Sweetness right there. :)

    Thanks again for you time.

    PS: Here's our work in progress: https://mike-b.totalitylms.com/api/docs

    Updates

    For things I have found answers to in the meantime, noting these here as these might help others out.

    • you can add a logo by adding the following to your spec file:
      {
        // ..
        "info": {
          "x-logo": {
              "url": "<url to image>",
              "altText": "<your logo alt text>"
          },
          // ...
        },
        // ...
      }
      
    • I realize now that things like theming and rendering, as well as automatic document generation are way out of scope of this package.
    • to get search to work, you must add the following to your content security policies:
      child-src: blob:;
      
    • to customize the theme:
      • publish this packages views: php artisan vendor:publish --provider="JustSteveKing\Laravel\LaravelRedoc\RedocServiceProvider"
      • customize the doc.blade.php view. It is important to note that the theme attribute must be in single-quotes, so that the json it contains uses double-quotes, otherwise it won't render.
           <redoc
             theme='{"colors": {"primary": { "main": "#FF5733"}}}'
             <!-- ... -->
           ></redoc>
        
      • see the following link for theming options: https://redoc.ly/docs/api-reference-docs/configuration/theming/#example-theme
    opened by mikebronner 1
  • Route Middleware

    Route Middleware

    Hi

    First off, great package and easy to use, we prefer to have our documentation sit behind authentication, however the current set up does not allow for middleware.

    I have created a pull request #6 to allow for middleware, it does have backwards compatibility with configs that may not have the path.middleware key.

    opened by johnathanmdell 0
Releases(1.0.0)
Owner
Steve McDougall
Consultant CTO, Freelance Software Engineer, Community Advocate. Founder at @PHPSouthWales Co-organiser at @BlueConf CTO at @Lila-Fuches
Steve McDougall
This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

Daniel Henze 3 Aug 29, 2022
Fanmade project using Twitter API and Marvel API.

Project Marvel Memories A fanmade project in PHP using API Twitter V2, Marvel API and Github action scheduler. What about? Posts a random cover with d

Julien SCHMITT 15 Dec 17, 2022
Package to fetch cryptocurrency price, market value, assets etc. using coincap API endpoints

cryptocap-pkg Package to fetch cryptocurrency price, market value, assets etc. using coincap API endpoints. This package was developed to work with co

Wisdom Diala 14 Nov 8, 2022
Generate pretty release changelogs using the commit log and Github API.

zenstruck/changelog Generate pretty release changelogs using the commit log and Github API. Changelog entries are in the following format: {short hash

Kevin Bond 3 Jun 20, 2022
It’s a bot using simple feature - jangan keseringan make (haram cok)

It’s a bot using simple feature - jangan keseringan make (haram cok)

null 2 Jan 26, 2022
It’s a bot using simple feature - jangan keseringan make (haram cok)

Indodax-machine It’s a bot using simple feature - jangan keseringan make (haram cok) Example of Request PHP (API-PANAS) Get Info Sample code below : <

null 2 Jan 26, 2022
PHP package providing easy and fast access to Twitter API V2.

Twitter API V2 is a PHP package that provides an easy and fast access to Twitter REST API for Version 2 endpoints.

Julien SCHMITT 38 Dec 12, 2022
Laravel 8.x package wrapper library for Metatrader 5 Web API

Laravel 8.x package wrapper library for Metatrader 5 Web API

Ali A. Dhillon 10 Nov 13, 2022
DigitalOcean API v2 client for Symfony and API Platform

DigitalOcean Bundle for Symfony and API Platform DunglasDigitalOceanBundle allows using the DigitalOcean API from your Symfony and API Platform projec

Kévin Dunglas 25 Jul 27, 2022
Nexmo REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.

Client Library for PHP Support Notice This library and it's associated packages, nexmo/client and nexmo/client-core have transitioned into a "Maintena

Nexmo 75 Sep 23, 2022
OpenAI API Client is a component-oriented, extensible client library for the OpenAI API. It's designed to be faster and more memory efficient than traditional PHP libraries.

OpenAI API Client in PHP (community-maintained) This library is a component-oriented, extensible client library for the OpenAI API. It's designed to b

Mounir R'Quiba 6 Jun 14, 2023
A simple PHP GitHub API client, Object Oriented, tested and documented.

PHP GitHub API A simple Object Oriented wrapper for GitHub API, written with PHP. Uses GitHub API v3 & supports GitHub API v4. The object API (v3) is

KNP Labs 2k Jan 7, 2023
Just a simple API PHP library with basic functions and config.

Installation Clone this Repository in your PHP Project git clone https://github.com/maximilianosinski/simple-api-php-library.git Change your Project n

Maximilian Osinski 1 May 9, 2022
PHP package to manage google-api interactions

Google-api-client PHP package to manage google-api interactions Supports: Google Drive API Google Spreadsheet API Installation composer require obrio-

OBRIO 3 Apr 28, 2022
PHP package for the Limg.app website - allowing to upload images via the API of the website.

Limg PHP Client Package. Installation You can install the package via composer: composer require havenstd06/limg-php-client Usage use Havenstd06\Limg\

Thomas 3 Jul 27, 2021
🌐 Free Google Translate API PHP Package. Translates totally free of charge.

Google Translate PHP Free Google Translate API PHP Package. Translates totally free of charge. Installation Basic Usage Advanced Usage Language Detect

Levan Velijanashvili 1.5k Dec 31, 2022
PHP GitHub Sponsors is a package that integrates directly with the GitHub Sponsors GraphQL API.

PHP GitHub Sponsors PHP GitHub Sponsors is a package that integrates directly with the GitHub Sponsors GraphQL API. Using it, you can easily check if

GitHub PHP 101 Nov 2, 2022
This package generates API resources with keys preset to their respective table's columns

Ever thought it was a bit tedious to define an API resource for a large table? This package makes life a bit simpler by presetting all columns in a Resource, so you can simply remove the ones you don't need, instead of adding the ones you need.

Protoqol 22 Jun 21, 2022