bra*_*eyl 5 amazon-web-services swagger-2.0 aws-api-gateway
假设我有一个包含路径/和/{pets}和的api /{pets}/pet。现在,我正在尝试验证path {pets}参数,以便仅验证长度为6的字母数字字符的路径并将其处理到后端lambda,所有其他路径将被拒绝。我尝试了下面的swagger模式,为参数指定了格式和类型。我什至尝试在模式中使用模式,但似乎无法正常工作。我可以知道我们如何仅限制某些ID的路径参数。
{
......
"/{pets}/pet": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [{
"name": "pets",
"in": "path",
"required": true,
"schema": {
"type": "string",
"pattern": "[A-Za-z0-9]{6}"
}
}],
"responses": {
"200": {
"description": "200 response",
"schema": {
"$ref": "#/definitions/Empty"
}
}
},
"x-amazon-apigateway-request-validator": "Validate query string parameters and headers",
"x-amazon-apigateway-integration": {
"responses": {
"default": {
"statusCode": "200"
}
},
"requestTemplates": {
"application/json": "## See ...."
},
"uri": "........",
"passthroughBehavior": "when_no_templates",
"httpMethod": "POST",
"contentHandling": "CONVERT_TO_TEXT",
"type": "aws"
}
}
}
.....
}
Run Code Online (Sandbox Code Playgroud)
我想要达到的目标:
https://api.example.com/aacc77/pet -- Accept
https://api.example.com/aacc77s/pet -- Reject
https://api.example.com/aacc7/pet -- Reject
https://api.example.com/aacc_7/pet -- Reject
Run Code Online (Sandbox Code Playgroud)
基本上,我想将此正则表达式模式用于路径[A-Za-z0-9] {6}。
"pets": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Pets Schema",
"type": "string",
"pattern": "[A-Za-z0-9]{6}"
}
Run Code Online (Sandbox Code Playgroud)
我看到有一个相关的问题在这里,我不知道是否有可用的一个解决方案。
| 归档时间: |
|
| 查看次数: |
1415 次 |
| 最近记录: |