承接 simklee/laravel-openapi 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

simklee/laravel-openapi

Composer 安装命令:

composer require simklee/laravel-openapi

包简介

Laravel OpenAPI

README 文档

README

The package Laravel OpenAPI generates a whole API for your models and creates a OpenAPI (Swagger) documentation by analysing the API routes and the generated code.

Installation

composer require simklee/laravel-openapi

After installation the command "openapi:install" will triggered through composer post install script.

It publishes the assets for the Swagger UI and creates "routes/api.php" (if not exists) and activates the API routes in "bootstrap/app.php" if not already activated.

Usage

Migrate your model before generating API! The generator fetches the column informations of a model from the database.

Configuration

Publish the configuration for ths package if you want to modify the settings.

php artisan vendor:publish --provider="SimKlee\LaravelOpenApi\LaravelOpenApiServiceProvider"
CategoryKeyDescription
DocumentationtitleThe title of your API documentation
DocumentationversionThe API version
Documentationdoc_pathThe path where to store the api.json
Documentationroute_filterThe used filter for the routes
Generatordefault_query_paramsThe defined query params for each method
Strategiesuse_paginator_for_indexUsing a paginator for index route
Strategiesuse_dto_in_requestUsing a DTO inside the specific request
Strategiesuse_abstract_model_api_controllerUsing a abstract controller
Strategiesuse_resourcesUsing a resource class for the JSON response

Create API for a model

Depending on the used configuration the following files will be generated or modified:

  • Abstract controller class (config: strategies.use_abstract_model_api_controller)
  • Controller class
  • Routes class
  • Specific request classes for each API method
  • DTOs for the request classes (config: strategies.use_dto_in_request)
  • Resource classes for each API method (config: strategies.use_resources)
  • Activating routes in "routes/api.php" by using specific routes class
php artisan openapi:generate:route

Remove API for a model

All generated files will be removed and the routes removed from "routes/api.php".

php artisan openapi:remove:route

Create OpenAPI (Swagger) documentation

The documentation will be generated based on the activated routes in "api.php" by analysing the generated code.

You can browse the Swagger documentation by calling the path "/swagger".

php artisan openapi:generate:doc

统计信息

  • 总下载量: 169
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-07