522

Product support

Get help in the plugin support forum.

  • Added on Nov 8, 2023
  • Current version: 1.0.5
  • Platform Compatibility
    v3.x use latest
    v2.x not tested
    v1.x not tested
  • Created by
  • Public repository

Categories

ApiDoc is a plugin for documenting the API.

Turns a regular PHP array into a documentation page

ApiDoc is a plugin for documenting the API.

Installation:

1st option: artisan plugin:install Gumennikov2002.ApiDoc

2nd option: Via marketplace

Document properties:

  • title (string, required)
  • tags (string[]) / tag (string)
  • url (string, required)
  • method (string, required)
  • params (array)
  • responses (array)

Parameter properties:

  • title (string, required)
  • description (string)
  • in (string, required)
  • required (boolean, required)
  • example (mixed, required)

Response properties:

  • status_code (int, required)
  • response (array, required)

Usage example:

In your plugin in the Plugin class, in the boot method, add the Gumennikov2002\ApiDoc\Controllers\Docs controller, assign its public docs property an array containing arrays with instructions.

Code example:

public function boot(): void
    {
        \Gumennikov2002\ApiDoc\Controllers\Docs::extend(function (\Backend\Classes\Controller $controller) {
            $controller->docs = [
                [
                    'title' => 'Get posts',
                    'tag' => 'Pосты',
                    'url' => 'https://example.com/api/v1/posts',
                    'method' => 'get',
                    'responses' => [
                        [
                            'status_code' => 200,
                            'response' => [
                                'data' => [
                                    [
                                        'id' => 1,
                                        'title' => 'First blog post!',
                                        'description' => 'No description provided...'
                                    ],
                                    [
                                        'id' => 2,
                                        'title' => 'Second blog post!',
                                        'description' => null
                                    ]
                                ]
                            ]
                        ]
                    ]
                ],
                [
                    'title' => 'Get post by ID',
                    'tag' => 'Posts',
                    'url' => 'https://example.com/api/v1/posts/{id}',
                    'method' => 'get',
                    'params' => [
                        [
                            'title' => 'id',
                            'description' => 'Post ID',
                            'in' => 'path',
                            'required' => true,
                            'example' => 1
                        ]
                    ],
                    'responses' => [
                        [
                            'status_code' => 200,
                            'response' => [
                                'data' => [
                                    'id' => 1,
                                    'title' => 'First blog post!',
                                    'description' => 'No description provided...'
                                ],
                            ]
                        ]
                    ]
                ]
            ];
        });
    }
1.0.5

Constructors removed

Dec 07, 2023

1.0.4

Plugin assets path

Nov 20, 2023

1.0.3

Show/Hide card body

Nov 13, 2023

1.0.2

Constructors

Nov 09, 2023

1.0.1

Api documentation

Nov 03, 2023