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

标签 amazon-web-services generics swagger generic-programming 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; }
}

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

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

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

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

最佳答案

fehguy 的回答对您更有帮助,但您从 API Gateway 获得的特定错误只是我们在 Swagger 规范中进行的额外验证。

Unable to create model for 'PaginationModel[DepartmentUIModel]': Model name must be alphanumeric: PaginationModel[DepartmentUIModel]



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

关于amazon-web-services - 从 Swagger 错误导入 Amazon API Gateway - 不采用泛型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37572531/

相关文章:

使用路径参数 Swagger

postgresql - 未处理的PromiseRejectionWarning : SequelizeConnectionError: database "dbname" does not exist

斯卡拉 : Collect with generics

generics - Typescript TSX 和通用参数

javascript - 如何在 TypeScript 中输入可配置的工厂函数?

java - 使用 Spring 在 Swagger UI 上收到 404 错误

amazon-web-services - Dynamodb 一次批量扫描与多次单次获取

amazon-web-services - "Target Groups"与 AWS 中的 "Auto-Scaling Groups"有何不同?

amazon-web-services - 无法使用 StreamExecutionEnvironment 使用 S3 接收器写入 S3 - Apache Flink 1.1.4

rest - Swagger 和 JSON 补丁