首页 文章

亚马逊API网关从Swagger导入错误 - 不使用泛型

提问于
浏览
3

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

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

代码模型定义:

public class PaginationModel<T>
{
    public IEnumerable<T> items { get; set; }
    public int offset { get; set; }
    public int totalCount { get; set; }
}

Swagger文件部分表示特定类型的Generic PaginationModel:

*"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时出错:

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

改变了'['with'<'和'{'但没有解决问题 .

除了为所有类型创建特定的分页模型之外,有没有办法让API Gateway了解Swagger的这个特定输出?

1 回答

  • 1

    fehguy的答案对您更有帮助,但您从API网关获得的具体错误只是我们在Swagger规范中所具有的额外验证 .

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

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

相关问题