Skip to main content
Version: 3.7

Interface 接口

1. 结构声明

class Interface extends ImportedInterface {
name: string = '';
originLogicName?: string;
path: string;
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
description: string;
params: Array<InterfaceParam>;
returns: Array<Return>;
validation?: BindAttribute;
}

2. 节点示例

(1) 示例

AST 如下:

{
"concept": "Interface",
"name": "phone",
"path": "/gw/getPhoneFrom/mobile/get",
"method": "GET",
"description": "",
"params": [
{
"concept": "InterfaceParam",
"name": "phone",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"in": "query",
"required": true
},
{
"concept": "InterfaceParam",
"name": "key",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"in": "query",
"required": true,
"defaultValue": {
"concept": "DefaultValue",
"expression": {
"concept": "StringLiteral",
"value": ""
},
"playground": []
}
},
{
"concept": "InterfaceParam",
"name": "type",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"in": "query",
"required": false,
"defaultValue": {
"concept": "DefaultValue",
"expression": {
"concept": "StringLiteral",
"value": ""
},
"playground": []
}
}
],
"returns": [
{
"concept": "Return",
"name": "result",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "apis.getPhoneFrom.structures",
"typeName": "ApiReturnOfPhone",
"inferred": false,
"ruleMap": {}
}
}
]
}

对应的代码如下:

interface phone(
@(
description = "",
in = "query",
)
phone: Integer,
@(
description = "",
in = "query",
)
key: String = '',
@(
description = "",
in = "query",
)
type: String = '') => result: apis::getPhoneFrom::structures::ApiReturnOfPhone;