OAS 2 此页面适用于 OpenAPI 规范版本 2(以前称为 Swagger)。
要了解最新版本,请访问 OpenAPI 3 页面.
Swagger 扩展
扩展或供应商扩展是自定义属性,以
x-
开头,例如
x-logo
。它们可以用于描述标准 Swagger 规范未涵盖的额外功能。许多支持 Swagger 的 API 相关产品都使用扩展来记录其自身属性,例如 Amazon API Gateway、ReDoc、APIMatic 等。扩展在 API 规范的根级别以及以下位置受支持
info
部分
paths
部分,各个路径和操作
- 操作参数
响应
标签
- 安全方案
扩展值可以是基本类型、数组、对象或
null
。如果值是对象或对象数组,则对象的属性名称不需要以
x-
开头。
示例
使用 Amazon API Gateway 自定义授权器的 API 将包含类似于以下内容的扩展
securityDefinitions:
APIGatewayAuthorizer:
type: apiKey
name: Authorization
in: header
x-amazon-apigateway-authtype: oauth2
x-amazon-apigateway-authorizer:
type: token
authorizerUri: arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:account-id:function:function-name/invocations
authorizerCredentials: arn:aws:iam::account-id:role
identityValidationExpression: "^x-[a-z]+"
authorizerResultTtlInSeconds: 60
没有找到您要查找的内容? 询问社区
发现错误? 告诉我们