Swagger扩展
<p><span style="font-size:18px"><strong>• 1 x-any-method:Any接受所有请求类型</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#pathsObject" target="_blank">Paths Object</a> 属性扩展,表示该API接受所有HTTP请求类型。</p>
<p><strong>示例</strong><strong>:</strong></p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas"> paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> x-any-method: Any</span></p>
<p><span style="font-family:Consolas"> ...</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td style="vertical-align:top">
<p>x-any-method</p>
</td>
<td style="vertical-align:top">
<p>是</p>
</td>
<td style="vertical-align:top">
<p>String</p>
</td>
<td style="vertical-align:top">
<p>在取值为Any时,表示可接受的API请求类型。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 2 x-request-type:API请求类型</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,表示该API是否可以上架到云市场。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> x-request-type: PRIVATE</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td style="vertical-align:top">
<p>x-request-type</p>
</td>
<td style="vertical-align:top">
<p>是</p>
</td>
<td style="vertical-align:top">
<p>String</p>
</td>
<td style="vertical-align:top">
<p>API的请求类型,该API是否可以上架云市场,目前支持:</p>
<ul>
<li>PRIVITE:私有型,不上架云市场。</li>
<li>PUBLIC:公有型,上架云市场。</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p> <strong><span style="font-size:18px">• 3 x-auth-type:安全认证类型</span></strong></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,表示该API在平安云网关安全认证类型。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas"> ...</span></p>
<p><span style="font-family:Consolas"> paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> x-auth-type: APP_AUTH</span></p>
<p><span style="font-family:Consolas"> ...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td style="vertical-align:top">
<p>x-auth-type</p>
</td>
<td style="vertical-align:top">
<p>是</p>
</td>
<td style="vertical-align:top">
<p>String</p>
</td>
<td>
<p>API网关的安全认证类型,目前支持:</p>
<ul>
<li>APP_AUTH:调用API时,由平安云API网关服务负责对应用进行安全认证。</li>
<li>NO_AUTH:不需要认证。任何可以获取此API的应用,均可以调用。</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 4 x-signature-algorithm:签名算法</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,表示该API所使用的签名算法,当安全认证类型为APP_AUTH时需要设置该属性。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> x-signature-algorithm: H_MAC_SHA1</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td style="vertical-align:top">
<p>x-signature-algorithm</p>
</td>
<td style="vertical-align:top">
<p>是</p>
</td>
<td style="vertical-align:top">
<p>String</p>
</td>
<td>
<p>API网关支持的签名算法:</p>
<ul>
<li>H_MAC_SHA1</li>
<li>H_MAC_SHA256</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><strong><span style="font-size:18px">• 5 x-path-match-type:匹配模式</span></strong></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,表示该API的路径匹配模式。</p>
<p><strong>示例:</strong></p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> x-path-match-type: PREFIX</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>x-path-match-type</p>
</td>
<td style="vertical-align:top">
<p>是</p>
</td>
<td style="vertical-align:top">
<p>String</p>
</td>
<td>
<p>请求路径的匹配模式,目前支持:</p>
<p>• NORMAL:完整路径匹配,调用的请求路径需要与创建API时设置的请求PATH完全一致。</p>
<p>• PREFIX:前缀路径匹配,调用的请求路径以创建API时设置的请求PATH为前缀<strong>。</strong></p>
<p> 例如:/getUserInfo/test/AAA或/getUserInfo/test/BBB均可匹配到/getUserInfo/test,但不会匹配/getUserInfotest。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 6 x-request-cors:跨域</strong></span></p>
<p><strong>含义:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,表示该API是否支持跨域。</p>
<p><strong>示例:</strong></p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> x-request-cors: true</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>x-request-cors</p>
</td>
<td style="vertical-align:top">
<p>否</p>
</td>
<td style="vertical-align:top">
<p>String</p>
</td>
<td>
<p>是否支持跨域,默认情况是false:</p>
<p>• true:支持跨域</p>
<p>• false:不支持跨域</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 7 x-body-desc:请求体描述</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,用于描述API请求体内容。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> post:</span></p>
<p><span style="font-family:Consolas"> x-body-desc: The description of request body</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>x-body-desc</p>
</td>
<td style="vertical-align:top">
<p>否</p>
</td>
<td style="vertical-align:top">
<p>String</p>
</td>
<td>
<p>请求体描述。</p>
<p>请求方法可以是POST、PUT、PATCH、ANY等。</p>
</td>
</tr>
</tbody>
</table>
<p> <span style="font-size:18px"><strong>• 8 <a name="id_01">x-example</a>:入参定义示例</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#parameterObject" target="_blank">Parameter Object</a> 属性扩展,用于描述API请求参数的示例。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> parameters:</span></p>
<p><span style="font-family:Consolas"> - {description: request param in header, in: header, name: reqHeader, required: false,</span></p>
<p><span style="font-family:Consolas"> default: pingan, type: string, x-example: apigateway}</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>description</p>
</td>
<td>
<p>否</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>参数的相关描述信息。</p>
</td>
</tr>
<tr>
<td>
<p>name</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>参数的名称。</p>
</td>
</tr>
<tr>
<td>
<p>in</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>参数的位置,支持:path、query、header。</p>
</td>
</tr>
<tr>
<td>
<p>type</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>参数的属性值类型,支持:string、integer、number、boolean。</p>
</td>
</tr>
<tr>
<td>
<p>required</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>参数的属性值是否必填:</p>
<p>• true:必填</p>
<p>• false:可选</p>
</td>
</tr>
<tr>
<td>
<p>default</p>
</td>
<td>
<p>否</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>参数属性值的默认情况,当required为true时需要设置。</p>
</td>
</tr>
<tr>
<td>
<p>x-example</p>
</td>
<td>
<p>否</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>参数的属性值示例。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 9 x-backend-parameters:后端服务参数</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#parameterObject" target="_blank">Parameter Object</a> 属性扩展,用于指定API入参定义与后端服务参数的映射关系。</p>
<p><strong>.yaml</strong><strong>文件格式示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas"> parameters:</span></p>
<p><span style="font-family:Consolas"> - name: reqPath</span></p>
<p><span style="font-family:Consolas"> in: path</span></p>
<p><span style="font-family:Consolas"> required: true</span></p>
<p><span style="font-family:Consolas"> type: string</span></p>
<p><span style="font-family:Consolas"> x-backend-parameters:</span></p>
<p><span style="font-family:Consolas"> - {location: path, name: backPath}</span></p>
<p><span style="font-family:Consolas"> x-example: apigateway</span></p>
<p><span style="font-family:Consolas"> description: request param in path</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>.json</strong><strong>文件格式示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas"> "parameters":[</span></p>
<p><span style="font-family:Consolas"> {</span></p>
<p><span style="font-family:Consolas"> "name":"reqPath",</span></p>
<p><span style="font-family:Consolas"> "in":"path",</span></p>
<p><span style="font-family:Consolas"> "required":true,</span></p>
<p><span style="font-family:Consolas"> "type":"string",</span></p>
<p><span style="font-family:Consolas"> "description":"request param in path",</span></p>
<p><span style="font-family:Consolas"> "x-backend-parameters":[</span></p>
<p><span style="font-family:Consolas"> {</span></p>
<p><span style="font-family:Consolas"> "location":"path",</span></p>
<p><span style="font-family:Consolas"> "name":"backPath"</span></p>
<p><span style="font-family:Consolas"> }</span></p>
<p><span style="font-family:Consolas"> ],</span></p>
<p><span style="font-family:Consolas"> "x-example":"apigateway"</span></p>
<p><span style="font-family:Consolas"> }</span></p>
<p><span style="font-family:Consolas"> ],</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<p><!--[if gte mso 9]><xml>
<o:OLEObject Type="Embed" ProgID="PBrush" ShapeID="_x0000_i1025"
DrawAspect="Content" ObjectID="_1633961843">
</o:OLEObject>
</xml><![endif]--><img src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20193010165904-13a8654e9b96.png" style="height:26px; margin:0px; width:65px" />:后端服务参数依赖于入参参数,当定义有入参参数时,可将该参数映射为后端参数(入参定义,可参考<a href="#id_01" target="_blank">x-example</a>)</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>location</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>后端服务参数的位置,目前支持:path、query、header。</p>
</td>
</tr>
<tr>
<td>
<p>name</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>后端服务参数的名称。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 10 x-backend:后端服务类型</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,用于描述API后端服务类型。<strong> </strong></p>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>x-backend</p>
</td>
<td style="vertical-align:top">
<p>是</p>
</td>
<td style="vertical-align:top">
<p>string</p>
</td>
<td>
<p>后端服务类型,目前支持:HTTP/ HTTPS、MOCK</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 10.1 HTTP后端服务类型</strong></span></p>
<p><strong>含义</strong><strong>:后端服务类型</strong>为<strong>HTTP/ HTTPS</strong>时<strong>,</strong>API网关可转发HTTP/HTTPS协议的请求<strong>。</strong></p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">x-backend:</span></p>
<p><span style="font-family:Consolas">- {address:'http://10.10.10.10:8888',method:ANY,path:'/back/{backPath}/{consPath}/{sysPath}',timeout: 6000, type: HTTP}</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>type</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>后端服务类型:HTTP。</p>
</td>
</tr>
<tr>
<td>
<p>address</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>后端服务的地址。</p>
</td>
</tr>
<tr>
<td>
<p>path</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>后端服务的请求路径。</p>
</td>
</tr>
<tr>
<td>
<p>method</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>后端服务的请求方法:目前支持:GET、POST、PUT、DELETE、HEAD、OPTIONS、PATCH、ANY。</p>
</td>
</tr>
<tr>
<td>
<p>timeout</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>integer</p>
</td>
<td>
<p>后端请求超时阈值,取值范围:1-600000ms,默认情况是5000ms。</p>
</td>
</tr>
<tr>
<td>
<p>x-constant-parameters</p>
</td>
<td>
<p>否</p>
</td>
<td>
<p>Constatnt Object</p>
</td>
<td>
<p>常量参数,可参考<a href="#id_02" target="_blank">x-constant-parameters</a>。</p>
</td>
</tr>
<tr>
<td>
<p>x-system-parameters</p>
</td>
<td>
<p>否</p>
</td>
<td>
<p>System Object</p>
</td>
<td>
<p>系统参数,可参考<a href="#id_03" target="_blank">x-system-parameters</a>。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 10.2 MOCK后端服务类型</strong></span></p>
<p><strong>含义</strong><strong>:后端服务类型</strong>为<strong>MOCK</strong>时,主要用于API的调试环境,不调用后端服务,直接返回设置的结果给API调用方<strong>。</strong></p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">... </span></p>
<p><span style="font-family:Consolas"> x-backend:</span></p>
<p><span style="font-family:Consolas"> mockHeaders:</span></p>
<p><span style="font-family:Consolas"> - {name: PA001, value: 平安集团}</span></p>
<p><span style="font-family:Consolas"> - {name: PA011, value: 平安科技}</span></p>
<p><span style="font-family:Consolas"> mockResult: mock result</span></p>
<p><span style="font-family:Consolas"> type: MOCK</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>type</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>后端服务类型:MOCK。</p>
</td>
</tr>
<tr>
<td>
<p>mockResult</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>Mock返回结果。</p>
</td>
</tr>
<tr>
<td>
<p>mockHeaders</p>
</td>
<td>
<p>否</p>
</td>
<td>
<p>MockHeader Object</p>
</td>
<td>
<p>Mock响应头,可参考mockHeaders。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 10.2.1 mockHeaders:Mock响应头参数</strong></span></p>
<p><strong>含义</strong><strong>:</strong>MOCK响应头数据定义。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas"> mockHeaders:</span></p>
<p><span style="font-family:Consolas"> - {name: PA011, value: 平安科技}</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>name</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>MOCK响应头的参数名称。</p>
</td>
</tr>
<tr>
<td>
<p>value</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>MOCK响应头的参数取值。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 11 <a name="id_02">x-constant-parameters</a>:常量参数</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#parameterObject" target="_blank">Parameter Object<strong> </strong></a>属性扩展,在后端服务类型为HTTP时,可设置API网关的常量参数。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas"> x-constant-parameters:</span></p>
<p><span style="font-family:Consolas"> - {name: conPa, location: query, value: apigateway, description: The constant parameter in backend}</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>name</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>常量参数的名称。</p>
</td>
</tr>
<tr>
<td>
<p>value</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>常量参数的取值。</p>
</td>
</tr>
<tr>
<td>
<p>location</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>常量参数的位置,目前支持:path、query、header。</p>
</td>
</tr>
<tr>
<td>
<p>description</p>
</td>
<td>
<p>否</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>常量参数的相关描述信息。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 12 <a name="id_03">x-system-parameters</a>:系统参数</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#parameterObject" target="_blank">Parameter Object</a><strong> </strong>属性扩展,在后端服务类型为HTTP时,可设置API网关的系统参数。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas"> x-system-parameters:</span></p>
<p><span style="font-family:Consolas"> - {name: sysPa, location: query, value: PA-AG-RequestId}</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>name</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>系统参数的名称。</p>
</td>
</tr>
<tr>
<td>
<p>value</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>系统参数的取值:目前支持:</p>
<ul>
<li>PA-AG-RequestId:客户端发送或API网关生成的API请求标识ID。</li>
<li>PA-AG-Timestamp:客户端发送API请求时的时间戳。</li>
<li>PA-AG-Env:客户端调用API的环境,默认情况是线上环境release。</li>
<li>PA-AG-ClientIP:客户端的IP地址。</li>
<li>PA-AG-AppId:客户端使用的应用(APP)的标识ID。</li>
<li>PA-AG-GroupId:客户端调用的API所属分组的标识ID。</li>
<li>PA-AG-UserId:客户端使用的应用(APP)的所属账户ID(TenantUUID)。</li>
<li>PA-AG-Gateway-ChargeMode:调用API时付费模式。</li>
<li>PA-AG-Gateway-Timestamp:API网关接受并处理API请求的时间戳。</li>
</ul>
</td>
</tr>
<tr>
<td>
<p>location</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>系统参数的位置,目前支持:path、query、header。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 13 x-response-content-type:返回结果的内容类型</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,用于描述返回Content-type类型。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> x-response-content-type: application/xml;charset=utf-8</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>x-response-content-type</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>调用API返回结果的内容类型,目前支持:</p>
<ul>
<li>application/json;charset=utf-8:JSON格式。</li>
<li>text/plain;charset=utf-8:纯文本格式。</li>
<li>application/octet-stream;charset=utf-8:二进制流格式。</li>
<li>application/xml;charset=utf-8:XML解析格式。</li>
<li>text/html;charset=utf-8:HTML解析格式。</li>
<li>passthrough:透传Content-type。</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 14 x-response-success-result:成功的返回结果</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,用于描述调用API成功时的返回结果。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> x-response-success-result: success</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>x-response-success-result</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>调用API成功,返回的响应结果。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 15 x-response-failure-result:失败的返回结果</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object </a>属性扩展,用于描述调用API失败时的返回结果。</p>
<p><strong>示例</strong>:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> x-response-failure-result: error</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>x-response-failure-result</p>
</td>
<td>
<p>是</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>调用API失败,返回的响应结果。</p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:18px"><strong>• 16 x-description:错误码</strong></span></p>
<p><strong>含义</strong><strong>:</strong><a href="https://swagger.io/specification/v2/#operationObject" target="_blank">Operation Object</a> 属性扩展,用于描述调用API出错时的错误信息。</p>
<p>示例:</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#f7f8fa; vertical-align:top">
<p><span style="font-family:Consolas">...</span></p>
<p><span style="font-family:Consolas">paths:</span></p>
<p><span style="font-family:Consolas"> '/path':</span></p>
<p><span style="font-family:Consolas"> get:</span></p>
<p><span style="font-family:Consolas"> responses:</span></p>
<p><span style="font-family:Consolas"> '200': {description: success, x-description: 'success'}</span></p>
<p><span style="font-family:Consolas">...</span></p>
</td>
</tr>
</tbody>
</table>
<p><strong>参数说明</strong>:</p>
<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>参数</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>是否必选</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>类型</strong></p>
</td>
<td style="background-color:#ededed; vertical-align:top">
<p><strong>说明</strong></p>
</td>
</tr>
<tr>
<td>
<p>x-description</p>
</td>
<td>
<p>否</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>调用API出错时的错误码,可作为排查报错信息的索引。</p>
</td>
</tr>
</tbody>
</table>
提交成功!非常感谢您的反馈,我们会继续努力做到更好!