Interface 接口
结构声明
- TS Declaration
- Java Class
- JSON Schema
interface Interface {
"concept": "Interface" | "AuthInterface", // 产品概念
"name": string, // 接口名称
"originLogicName": string, // 导出的来源
"path": string, // 接口路径
"method": "GET" | "POST" | "PUT" | "DELETE", // 接口方法
"description": string, // 接口描述
"params": Array<InterfaceParam>, // 接口参数列表
"returns": Array<Return>, // 输出参数列表
"validation": BindAttribute, // 验证规则
}
class InterfaceTreeNode {
ConceptEnum concept; // 产品概念
String name; // 接口名称
String originLogicName; // 导出的来源
String path; // 接口路径
MethodEnum method; // 接口方法
String description; // 接口描述
List<InterfaceParamTreeNode> params; // 接口参数列表
List<ReturnTreeNode> returns; // 输出参数列表
BindAttributeTreeNode validation; // 验证规则
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/Interface",
"definitions": {
"Interface": {
"type": "object",
"properties": {
"concept": {
"type": "string",
"enum": [
"Interface",
"AuthInterface"
]
},
"name": {
"type": "string"
},
"originLogicName": {
"type": "string"
},
"path": {
"type": "string"
},
"method": {
"type": "string",
"enum": [
"GET",
"POST",
"PUT",
"DELETE"
]
},
"description": {
"type": "string"
},
"params": {
"type": "array",
"items": {
"$ref": "#/definitions/InterfaceParam"
}
},
"returns": {
"type": "array",
"items": {
"$ref": "#/definitions/Return"
}
},
"validation": {
"$ref": "#/definitions/BindAttribute"
}
},
"required": [
"concept",
"name",
"originLogicName",
"path",
"method",
"description",
"params",
"returns",
"validation"
],
"additionalProperties": false
}
}
}
示例
简单示例
- JSON
- YAML
{
"concept": "Interface",
"name": "GetUserList",
"originLogicName": "logic1",
"path": "GetUserList",
"method": "GET",
"description": "这是一个接口",
"params": [],
"returns": [],
"validation": null
}
concept: Interface
name: GetUserList
originLogicName: logic1
path: GetUserList
method: GET
description: 这是一个接口
params: []
returns: []
validation: null
ScopeOf
- JSON
- Embedded in TS
{}
declare function interface1(options: {
query1?: nasl.core.String;
query2?: nasl.core.String;
body: app.course.Student;
}): ApiReturnOf<Student>;