从 Swagger 错误导入 Amazon API Gateway - 不采用泛型

Ale*_*lex 5 generics generic-programming amazon-web-services swagger aws-api-gateway

我正在尝试通过从 Swagger 导入来创建新的 APIGateway,但出现验证错误:

导致问题的特定类是我们的 PaginationModel 类。

代码模型定义:

public class PaginationModel<T>
{
    public IEnumerable<T> items { get; set; }
    public int offset { get; set; }
    public int totalCount { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

Swagger 文件部分表示特定类型的通用分页模型:

*"PaginationModel[DepartmentUIModel]":{"type":"object","properties":{"items":    {"type":"array","items":{"$ref":"#/definitions/DepartmentUIModel"}},"offset":    {"format":"int32","type":"integer"},"totalCount":{"format":"int32","type":"integer"}}}*
Run Code Online (Sandbox Code Playgroud)

将 Swagger 文件导入 Amazon API Gateway 时出错:

无法为“PaginationModel[DepartmentUIModel]”创建模型:模型名称必须是字母数字:PaginationModel[DepartmentUIModel]

用 '<' 和 '{' 更改了 '[' 但没有解决问题。

除了为所有类型创建特定的分页模型之外,还有什么方法可以让 API Gateway 理解 Swagger 的这个特定输出?

Jac*_*AWS 2

fehguy 的答案对您更有帮助,但是您从 API Gateway 收到的具体错误只是我们在 Swagger 规范中进行的额外验证。

无法为“PaginationModel[DepartmentUIModel]”创建模型:模型名称必须是字母数字:PaginationModel[DepartmentUIModel]

型号名称必须是字母数字,这意味着它们必须匹配正则表达式“[a-zA-Z0-9]+”