Amazon API Gateway Import From Swagger 错误 - 不采用泛型 [英] Amazon API Gateway Import From Swagger Error - Not taking Generics

查看:22
本文介绍了Amazon API Gateway Import From Swagger 错误 - 不采用泛型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过从 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; }
}

代表特定类型的通用分页模型的 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.

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

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

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

Model names must be alphanumeric, meaning they have to match the regex "[a-zA-Z0-9]+"

这篇关于Amazon API Gateway Import From Swagger 错误 - 不采用泛型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆