Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon API Gateway Import From Swagger Error - Not taking Generics

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?

like image 625
Alex Avatar asked Nov 08 '22 14:11

Alex


1 Answers

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]+"

like image 181
jackko Avatar answered Nov 14 '22 21:11

jackko