1. How HTTP carries information
url
headers
body: including the request body , Response body
2. Separate common information
Generally speaking, the information in headers is universal and can be stated in advance as the default parameters
3. Parameter expression in the path
The parameter expression in the URL uses the form of mustache, and the parameter is wrapped in double curly brackets {{paramName}}
Related recommendations: "php Getting Started Tutorial"
For example:
/api/user/{{userId}} /api/user/{{userType}}?age={{age}}&gender={{gender}}
4. Data model definition
Data model definition Including:
·Path and query string parameter model
·Request body parameter model
·Response body parameter model
Minimum data set of data model:
Name
Is it required
Description
“最小数据集”(MDS)是指通过收集最少的数据,较好地掌握一个研究对象所具有的特点或一件事情、一份工作所处的状态, 其核心是针对被观察的对象建立起一套精简实用的数据指标。最小数据集的概念起源于美国的医疗领域。最小数据集的产生源于信息 交换的需要,就好比上下级质量技术监督部门之间、企业与质量技术监督部门之间、质量技术监督部门与社会公众之间都存在着信息 交换的需求。
Some documents may add field types, but I think this is unnecessary. It is thought that the data transmitted by HTTP often needs to be serialized, and most data types are strings. Some special types, such as enumeration type strings, can be described in the description.
In addition: It is highly recommended to use tables to express the data model.
The above is the detailed content of How to write php interface document. For more information, please follow other related articles on the PHP Chinese website!