Amazon API Gateway Import From Swagger Error - Not taking Generics

人盡茶涼 提交于 2021-02-07 14:21:35

问题


I'm trying to create new APIGateway via import from Swagger, but having validation errors:

The particular class causing the issue is our PaginationModel class.

Code model definition:

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

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"}}}*

Error when importing Swagger file into Amazon API Gateway:

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

Changed the '[' with '<' and '{' but not solving the problem.

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?


回答1:


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.

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

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



来源:https://stackoverflow.com/questions/37572531/amazon-api-gateway-import-from-swagger-error-not-taking-generics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!