chalice icon indicating copy to clipboard operation
chalice copied to clipboard

Question: Working backward from existing Swagger spec?

Open bobspryn opened this issue 7 years ago • 3 comments

👋

Building my first serverless application here and my head is swimming a bit. I have a defined swagger spec that my mobile client is working against. Swagger has the ability to generate code from a spec for flask, and other similar style frameworks in different languages.

Is there such a thing for chalice? Does that even make sense? Does having an existing spec net me anything here?

Should I use flask instead?

bobspryn avatar Jul 22 '18 02:07 bobspryn

Just for my own clarity, this would be a request to have some tool that takes a swagger document (or some other IDL document) and from that generate a stub of an app.py file to use in Chalice?

Nothing like that currently exists as far as I know. You can always use Chalice to deploy an API and then get the swagger document describing the API from API Gateway and use that to generate clients. This will treat the Chalice app as the source of truth for the API definition.

stealthycoin avatar Jul 25 '18 20:07 stealthycoin

Right. So there is this: https://github.com/swagger-api/swagger-codegen

Which is used to take a spec and generate various bits for various clients/servers. The main python solution is using Connexion/Flask. It generates some model code, but mostly just hooks up Connexion which points requests in the right direction at runtime based on the swagger.yaml file.

Some solutions are dynamic like that, some just generate your starting stubs.

bobspryn avatar Jul 25 '18 20:07 bobspryn

Connexion is used by swagger-codegen, but stands on its own as a valdiation, routing, and serialization layer on top of Flask, driven by an existing OpenAPI spec as the source of truth, instead of generating one from Python code.

It looks like there's work underway to make the next major version of Connexion more pluggable, and independent of a particular framework. Perhaps pieces of that could be used in a Chalice app.

bhrutledge avatar Jun 13 '22 21:06 bhrutledge