从现有的 Laravel 应用中生成美观的交互式文档和 Open-API 3.0 规范文件。
Follow me anywhere @ovac4u | GitHub
_________ _________ | Twitter
| ___ |.-----.--.--.---.-.----.| | |.--.--. | Facebook
| | _ || _ | | | _ | __||__ | | | | Instagram
| |______||_____|\___/|___._|____| |__||_____| | GitHub + @ovac
|_________| www.ovac4u.com | Facebook + @ovacpostsLaravel IDoc generator (interactive documentation generator) is a seamless and complete plugin for generating API documentation from your Laravel's codebase. It is inspired by the laravel-apidoc-generator, ReDoc and the Open API initiative from Swagger. IDoc has been built with extendability so that it can easily adapt with your use case.
{.inline}
{.inline}
{.inline}
Responsive three-panel design with menu/scrolling synchronization
Integrate API Introduction into side menu.
High-level grouping in side-menu.
Branding/customizations.
Redoc OSS for fast, beautiful reading
Optional Swagger UI side panel for live "Try it" requests
Tag or operation aware, stays in sync while you navigate
Note: PHP 7 and Laravel 5.5 or higher are the minimum dependencies.
$ composer require ovac/idocPublish the config file by running:
php artisan vendor:publish --tag=idoc-configThis will create an idoc.php file in your config folder.
bootstrap/app.php:$app->bind('path.public', function ($app) { return $app->basePath('../your-public-path'); });
$app->register(\OVAC\IDoc\IDocLumenServiceProvider::class);vendor/ovac/idoc/config/idoc.php to your project as config/idoc.php. Then add to your bootstrap/app.php:$app->configure('idoc');$ php artisan idoc:generateThe docs page ships with an optional, provider-agnostic AI assistant (ChatGPT‑style) that answers questions about your API using your generated OpenAPI document and optional extra context from a Blade view.
### GET /path, the UI shows “Open endpoint” and “Try it with this data”. Try It auto-fills parameters/body from your message and executes.{ version: "idoc-1", messages: [...] }).php artisan vendor:publish --tag=idoc-prompts
# Edit resources/vendor/idoc/prompts/chat-system.mdIDOC_CHAT_SYSTEM_PROMPT env var or idoc.chat.system_prompt_md in config.Add to your .env:
IDOC_CHAT_ENABLED=true
IDOC_CHAT_PROVIDER=deepseek
IDOC_CHAT_MODEL=deepseek-chat
IDOC_CHAT_BASE_URL=https://api.deepseek.com/v1
DEEPSEEK_API_KEY=your_deepseek_keyReload config/cache:
php artisan config:clear && php artisan cache:clearIDOC_CHAT_ENABLED=true
IDOC_CHAT_PROVIDER=openai
IDOC_CHAT_MODEL=gpt-4o-mini
IDOC_CHAT_BASE_URL=https://api.openai.com/v1
OPENAI_API_KEY=your_openai_keyIDOC_CHAT_ENABLED=true
IDOC_CHAT_PROVIDER=google
IDOC_CHAT_MODEL=gemini-1.5-flash
IDOC_CHAT_BASE_URL=https://generativelanguage.googleapis.com/v1beta
GOOGLE_API_KEY=your_google_api_keyIDOC_CHAT_ENABLED=true
IDOC_CHAT_PROVIDER=groq
IDOC_CHAT_MODEL=mixtral-8x7b-32768
IDOC_CHAT_BASE_URL=https://api.groq.com/openai/v1
GROQ_API_KEY=your_groq_keyIDOC_CHAT_ENABLED=true
IDOC_CHAT_PROVIDER=huggingface
IDOC_CHAT_MODEL=Qwen/Qwen2.5-7B-Instruct
IDOC_CHAT_BASE_URL=https://api-inference.huggingface.co
HF_API_TOKEN=your_hf_tokenIDOC_CHAT_ENABLED=true
IDOC_CHAT_PROVIDER=openai
IDOC_CHAT_BASE_URL=http://127.0.0.1:8000/v1
IDOC_CHAT_MODEL=qwen2.5-7b-instruct
IDOC_CHAT_API_KEY=localdevTip: If Chat isn’t required, disable it by setting IDOC_CHAT_ENABLED=false.
web for chat and adds only throttling (throttle:60,1).chat.remove_middleware, or switch to a session‑backed chat by adding the session trio (EncryptCookies, AddQueuedCookiesToResponse, StartSession) to chat.middleware.web may be included via the idoc group, iDoc excludes it for chat at group time when you set chat.remove_middleware.config/idoc.php.Before you can generate your documentation, you'll need to configure a few things in your config/idoc.php.
path
This will be used to register the necessary routes for the package.'path' => 'idoc',logo
You can specify your custom logo to be used on the generated documentation. A relative or absolute url to the logo image.'logo' => 'https://res.cloudinary.com/ovac/image/upload/h_300,w_380,c_fill,r_30,bo_20px_solid_white/aboust_ey5v1v.jpg',title
Here, you can specify the title to place on the documentation page.'title' => 'iDoc API Reference',description
This will place a description on top of the documentation.'description' => 'iDoc API specification and documentation.',version
Documentation version number.
terms_of_service
This is the url to the terms and conditions for use your API.
contact
Here you can configure contact information for support.
'contact' => [
'name' => 'API Support',
'email' => '[email protected]',
'url' => 'http://www.ovac4u.com'
],license
A short and simple permissive license with conditions only requiring preservation of copyright and license notices'license' => [
'name' => 'MIT',
'url' => 'https://github.com/ovac/idoc/blob/master/LICENSE.md'
],output
This package can automatically generate an Open-API 3.0 specification file for your routes, along with the documentation. This is the file path where the generated documentation will be written to. Default: public/docs
resources
Locations of external resources, that can be customised for self-hosting if required.
'resources' => [
'fonts' => '//fonts.googleapis.com/css?family=Roboto:400,700',
'redoc_standalone_js' => 'https://cdn.jsdelivr.net/npm/[email protected]/bundles/redoc.standalone.js',
'swagger_css' => 'https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css',
'swagger_ui_js' => 'https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js',
],hide_download_button
This section is where you can configure if you want a download button visible on the documentation.
router
The router to use when processing the route (can be Laravel or Dingo. Defaults to Laravel)
servers
The servers array can be used to add multiple endpoints on the documentation so that the user can switch between endpoints. For example, This could be a test server and the live server.
'servers' => [
[
'url' => 'https://www.ovac4u.com',
'description' => 'App live server.',
],
[
'url' => 'https://test.ovac4u.com',
'description' => 'App test server.',
],
],tag_groups
This array is used to separate groups that you have defined in little sections in the side menu. If you want to use it, make sure you add all groups because the unadded group will not be displayed.
external_description
This option allows you to specify a route name for an external description that will be used in the documentation. If not provided, it will default to the route idoc.info. By default, it is set to idoc.info.
'external_description' => 'idoc.info', // Route name for external description, leave empty to use default descriptionExample usage:
'external_description' => 'idoc.info',language-tabs
This is where you can set languages used to write request samples. Each item in array is used to generate a request template for a given language. New languages can be added and the existing ones modified after. You can add or edit new languages tabs by publishing the view files and editing them or adding custom view files to:'resources/views/vendor/idoc/languages/LANGUAGE.blade.php',security
This is where you specify authentication and authorization schemes, by default the HTTP authentication scheme using Bearer is setting but you can modify it, add others or even define it as null according to the requirements of your project. For more information, please visit Swagger Authentication.'security' => [
'BearerAuth' => [
'type' => 'http',
'scheme' => 'bearer',
'bearerFormat' => 'JWT',
],
],routes
This is where you specify what rules documentation should be generated for. You specify routes to be parsed by defining conditions that the routes should meet and rules that should be applied when generating documentation. These conditions and rules are specified in groups, allowing you to apply different rules to different routes.For instance, suppose your configuration looks like this:
…This means documentation will be generated for routes in all domains ('*' is a wildcard meaning 'any character') which match any of the patterns 'api/*' or 'v2-api/*', excluding the 'users.create' route and any routes whose names begin with admin., and including the 'users.index' route and any routes whose names begin with healthcheck.. (The versions key is ignored unless you
暂无开放 Issues,或尚未同步最近议题。