用swagger-php/ui作API测试
用swagger-php/ui做API测试
功能:
1 swagger-php根据自定义的规则生成API请求规则,通过phar生成json文件
2 打开swagger-ui/dist/index.html。输入json文件夹目录地址(需要同源),swagger-ui会根据请求的JSON生成API,页面很漂亮。输入请求参数后执行会获取返回值。
缺点:不能对返回的数据进行验证。功能类似chrome的插件postman。
Api Action测试参考代码:
Resource/PostAction.php
<?php/** * @SWG\Resource( * apiVersion="2.2.0", * swaggerVersion="1.2", * basePath="http://test.xxx.com/Api/Post", * resourcePath="/Post", * description="Operations about Post", * produces="['application/json']" * ) *//** * @SWG\Api( * path="/apps", * @SWG\Operation( * method="POST", * summary="Find app by buID", * notes="Returns apps based on BUID", * type="Post", * nickname="apps", * authorizations={}, * @SWG\Parameter( * name="apiVersion", * description="api version", * required=true, * type="integer", * format="int64", * paramType="form", * minimum="1.0", * allowMultiple=false * ), * @SWG\Parameter( * name="sessionID", * description="user login session", * required=true, * type="string", * paramType="form", * defaultValue="9f6cdd0858a1e93b1426659b283a93ec", * allowMultiple=false * ), * @SWG\Parameter( * name="buID", * description="BU ID", * required=true, * type="int64", * paramType="form", * allowMultiple=false * ), * @SWG\ResponseMessage(code=400, message="Invalid ID supplied"), * @SWG\ResponseMessage(code=404, message="Post not found"), * @SWG\ResponseMessage(code=405, message="Invalid input"), * @SWG\ResponseMessage(code=200, message="success") * ) * ) */
项目描述信息
Info/api.php
<?php/** * @SWG\Info( * title="MY Project", * description=" xxx", * ) * */
readme
# Usage of API Docs### Raw Spec Structure* Info - General Info.* Model - Entity Class* Resource - API endpoint### Compile API info.* after modify the spec, run shell script, as follows. `cd api-docs` `./genDocumentation.sh`* the compiled content (.json) is stored in documentation/Output/### View API docs* visit http://{domain}/documenation/
sh 执行文件
#!/bin/sh../swagger-php/swagger.phar ../output-docs -o ../documentation/output/

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to crawl and process data by calling API interface in PHP project? 1. Introduction In PHP projects, we often need to crawl data from other websites and process these data. Many websites provide API interfaces, and we can obtain data by calling these interfaces. This article will introduce how to use PHP to call the API interface to crawl and process data. 2. Obtain the URL and parameters of the API interface. Before starting, we need to obtain the URL of the target API interface and the required parameters.

Title: How to deal with Laravel API error problems, specific code examples are needed. When developing Laravel, API errors are often encountered. These errors may come from various reasons such as program code logic errors, database query problems, or external API request failures. How to handle these error reports is a key issue. This article will use specific code examples to demonstrate how to effectively handle Laravel API error reports. 1. Error handling in Laravel

Oracle is a world-renowned database management system provider, and its API (Application Programming Interface) is a powerful tool that helps developers easily interact and integrate with Oracle databases. In this article, we will delve into the Oracle API usage guide, show readers how to utilize data interface technology during the development process, and provide specific code examples. 1.Oracle

ReactAPI Call Guide: How to interact with and transfer data to the backend API Overview: In modern web development, interacting with and transferring data to the backend API is a common need. React, as a popular front-end framework, provides some powerful tools and features to simplify this process. This article will introduce how to use React to call the backend API, including basic GET and POST requests, and provide specific code examples. Install the required dependencies: First, make sure Axi is installed in the project

OracleAPI integration strategy analysis: To achieve seamless communication between systems, specific code examples are required. In today's digital era, internal enterprise systems need to communicate with each other and share data, and OracleAPI is one of the important tools to help achieve seamless communication between systems. This article will start with the basic concepts and principles of OracleAPI, explore API integration strategies, and finally give specific code examples to help readers better understand and apply OracleAPI. 1. Basic Oracle API

In the world of data-driven applications and analytics, APIs (Application Programming Interfaces) play a vital role in retrieving data from various sources. When working with API data, you often need to store the data in a format that is easy to access and manipulate. One such format is CSV (Comma Separated Values), which allows tabular data to be organized and stored efficiently. This article will explore the process of saving API data to CSV format using the powerful programming language Python. By following the steps outlined in this guide, we will learn how to retrieve data from the API, extract relevant information, and store it in a CSV file for further analysis and processing. Let’s dive into the world of API data processing with Python and unlock the potential of the CSV format

Development suggestions: How to use the ThinkPHP framework for API development. With the continuous development of the Internet, the importance of API (Application Programming Interface) has become increasingly prominent. API is a bridge for communication between different applications. It can realize data sharing, function calling and other operations, and provides developers with a relatively simple and fast development method. As an excellent PHP development framework, the ThinkPHP framework is efficient, scalable and easy to use.

How to use MongoDB to develop a simple CRUD API In modern web application development, CRUD (Create, Delete, Modify, Check) operations are one of the most common and important functions. In this article, we will introduce how to develop a simple CRUD API using MongoDB database and provide specific code examples. MongoDB is an open source NoSQL database that stores data in the form of documents. Unlike traditional relational databases, MongoDB does not have a predefined schema
