GithubHelp home page GithubHelp logo

youneselbarnoussi / automated-api-docs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from owowagency/automated-api-docs

0.0 0.0 0.0 21 KB

A package for automated API documentation

PHP 98.03% HTML 1.97%

automated-api-docs's Introduction

Auto generated documentation for APIs

Installation

Installation and setup time is estimated to be around 5 to 10 minutes. Install this package via composer.

composer require owowagency/automated-api-docs

If you're using Laravel >= 5.5 this package will automatically be added to your providers list. If using a lower version, add the service provider to the providers array in config/app.php.

OwowAgency\AutomatedApiDocs\ServiceProvider::class,

You're now ready for setup.

The package comes with a config file. The default config should be good in most use cases. However, feel free to change it. To publish the config file run the following command

php artisan vendor:publish --provider="OwowAgency\AutomatedApiDocs\ServiceProvider" --tag="config"

Setup

After installation, and optionally configuration, we need to setup the package. The package usage a hook in the HTTP calls to your app via the feature tests to monitor all requests and responses.

Firstly, you need to use the trait to enable to monitor hook.

use OwowAgency\AutomatedApiDocs\DocsGenerator;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication, DocsGenerator;
}

Secondly, you need to register a shutdown function so that the package now when to parse the docs into a custom format which is readable for the parsers.

protected function setUp(): void
{
    parent::setUp();
    

    $config = config('automated-api-docs');

    register_shutdown_function(function () use ($config) {
        $this->exportDocsToJson($config);
    });
}

Next, you need to add this file to the root of your Laravel application. If this file already exists in your app you probably only need to copy the documentation task.

Finally, make sure to add the following command envoy run documentation in your deployment script. For example on Laravel Forge.

You're now ready to register all the monitor hooks. You can do that by calling the monitor() method before calling a route.

public function test_foo()
{
    $user = factory(User::class)->create();
    
    $this->actingAs($user)->monitor()->post('/v1/posts', [
        'title' => 'Foo bar',
    ]);
}

automated-api-docs's People

Contributors

dees040 avatar dependabot-preview[bot] avatar thomasowow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.