Having Swagger Native to Serverless Framework



I know there have been various threads on this and some plugins (serverless-reqvalidator-plugin, serverless-aws-documentation) and Cloudformation ( AWS::ApiGateway::RequestValidator) bits to help integrate. All IMHO are an exercise in too much cut and paste. Today if I use the AWS API Gateway console I can very quickly import a swagger file and I am done. Here are some thoughts on how I imagine it might work natively:

  • Continue the current functions format.
  • Under events add a new element called swagger. Under this element you would still define the path, method, etc. but add an artifact element giving the path to the swagger file. I would imagine if we parsed that file and match serverless path and method to the swagger path and respective http method, we could build a CloudFormation template that emulates the API Gateway import feature?

This would simplify the serverless.yml allot. Why do this? Well Swagger is a spec for defining REST APIs. Legacy APIs that used Swagger can now have an easier pathway to using serverless. You get out of the box a model and validator for your APIs.

Being a Java guy maybe I should just learn Node and build this myself?