问题描述
我正在尝试通过从Swagger导入来创建新的APIGateway,但是出现验证错误:
I'm trying to create new APIGateway via import from Swagger, but having validation errors:
引起问题的特定类是我们的PaginationModel类.
The particular class causing the issue is our PaginationModel class.
代码模型定义:
public class PaginationModel<T>
{
public IEnumerable<T> items { get; set; }
public int offset { get; set; }
public int totalCount { get; set; }
}
代表特定类型的通用PaginationModel的Swagger文件部分:
Swagger file section representing Generic PaginationModel for a particular type:
*"PaginationModel[DepartmentUIModel]":{"type":"object","properties":{"items": {"type":"array","items":{"$ref":"#/definitions/DepartmentUIModel"}},"offset": {"format":"int32","type":"integer"},"totalCount":{"format":"int32","type":"integer"}}}*
将Swagger文件导入Amazon API Gateway时出错:
Error when importing Swagger file into Amazon API Gateway:
无法为'PaginationModel [DepartmentUIModel]'创建模型:模型名称必须为字母数字:PaginationModel [DepartmentUIModel]
将'['更改为'<'和"{",但不能解决问题.
Changed the '[' with '<' and '{' but not solving the problem.
除了为所有类型创建特定的分页模型之外,还有什么方法可以使API网关理解Swagger的特定输出?
Other than creating specific Pagination models for all types, is there a way I can make the API Gateway understand this particular output from Swagger?
推荐答案
fehguy的答案对您更有帮助,但是您从API Gateway得到的特定错误只是我们在昂首阔步的规格.
fehguy's answer is more helpful to you, but the specific error you're getting from API Gateway is just extra validation that we have on top of what is in the Swagger spec.
模型名称必须为字母数字,这意味着它们必须与正则表达式"[a-zA-Z0-9] +"匹配
Model names must be alphanumeric, meaning they have to match the regex "[a-zA-Z0-9]+"
这篇关于从Swagger错误导入Amazon API Gateway-不采用泛型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!