问题
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