Amazon API 从 Swagger 错误导入网关 - 不采用泛型
Amazon API Gateway Import From Swagger Error - Not taking Generics
我正在尝试通过从 Swagger 导入创建新的 API 网关,但出现验证错误:
导致问题的特定 class 是我们的分页模型 class。
代码模型定义:
public class PaginationModel<T>
{
public IEnumerable<T> items { get; set; }
public int offset { get; set; }
public int totalCount { get; set; }
}
表示特定类型的通用分页模型的 Swagger 文件部分:
*"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 网关:
无法为 'PaginationModel[DepartmentUIModel]' 创建模型:模型名称必须是字母数字:PaginationModel[DepartmentUIModel]
将“[”更改为“<”和“{”,但未解决问题。
除了为所有类型创建特定的分页模型之外,有没有办法让 API 网关理解 Swagger 的这个特定输出?
fehguy 的回答对您更有帮助,但是您从 API Gateway 得到的具体错误只是我们在 Swagger 规范之上的额外验证。
Unable to create model for 'PaginationModel[DepartmentUIModel]': Model name must be alphanumeric: PaginationModel[DepartmentUIModel]
模型名称必须是字母数字,这意味着它们必须匹配正则表达式“[a-zA-Z0-9]+”
我正在尝试通过从 Swagger 导入创建新的 API 网关,但出现验证错误:
导致问题的特定 class 是我们的分页模型 class。
代码模型定义:
public class PaginationModel<T>
{
public IEnumerable<T> items { get; set; }
public int offset { get; set; }
public int totalCount { get; set; }
}
表示特定类型的通用分页模型的 Swagger 文件部分:
*"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 网关:
无法为 'PaginationModel[DepartmentUIModel]' 创建模型:模型名称必须是字母数字:PaginationModel[DepartmentUIModel]
将“[”更改为“<”和“{”,但未解决问题。
除了为所有类型创建特定的分页模型之外,有没有办法让 API 网关理解 Swagger 的这个特定输出?
fehguy 的回答对您更有帮助,但是您从 API Gateway 得到的具体错误只是我们在 Swagger 规范之上的额外验证。
Unable to create model for 'PaginationModel[DepartmentUIModel]': Model name must be alphanumeric: PaginationModel[DepartmentUIModel]
模型名称必须是字母数字,这意味着它们必须匹配正则表达式“[a-zA-Z0-9]+”