AWS API Gateway - Getting Started

Im trying to understand how to take our existing servicestack application and make it work with the AWS API Gateway…

I understand that the API gateway support Swagger and OpenAPI and so does servicestack.

With my very nieve understanding, I’m GUESSING that if I use service stack to generate an swagger file


Save it and import it into the AWS API gateway, this might be the starting point to configure API Gateway?

When i do so i get this error.

Your API was not imported due to errors in the Swagger file.
Unable to create model for ‘xxxxx’: Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]

I’m not really sure if what I’m trying is possible or needed.

I know I could simply expose the IP of our self-hosted app that’s running in a container and be done with it, but then i would not have capabilities provided by the API gateway such as DDOS management and AWS IAM permission management.

I also see that the AWS API sample swagger source, starts with

“swagger”: “2.0”,

Which maps to the SS Openapi package and not the SS swagger package.

I don’t know if it’s possible to import it into AWS API Gateway, but the path to the Open API endpoint is /openapi.

But I couldn’t tell you what the cause of the error is, you could try to cut down the JSON to see if it can import a single service.

Do many/any of other servicestack users who host on Amazon use the api gateway?

We only get notified when people are having issues, not when something is getting used. The only issue I can recall that used AWS API Gateway was an AWS Lambda .NET Core issue:

Although they didn’t use Open API, they used Serverless to manage their AWS lambda functions and listed their API endpoints in their serverless.yml.

FYI, was talking with amazon consultants today. They reviewed the file generated by the call to /openapi. Apparently, the AWS API Gateway openapi/swagger implementation has several known deficiencies.

From a quick scan, there are a few swagger primitives that servicestack uses that are not supported are:

  • The additionalProperties field is not supported in Models.
  • Numbers of the Int32 or Int64 type is not supported.

They said it would still be possible to use the API gateway by using their GUI to add individual calls for each path we want to support. In our case that would be too much for the value, it would provide.

Instead, they pointed me to use an Application Level Load Balancer in EC2 to proxy access to the rest calls.

We’re testing that now.

1 Like