Comments (6)
fyi, I asked the author of the serverless-plugin-swagger-export
module/plugin similar questions, here:
kennu/serverless-plugin-swagger-export#1
from serverless-models-plugin.
Thanks for the comments. Currently the plugins are distinct. The purpose of this plugin is to be able to define and upload model definitions along and integrated with the function definitions in an easy way, what it currently not supported by Serverless at all.
As long as models are not integrated into Serverless core it would be hard for the export plugin to use the model definitions.
What I could think of, would be a definitions export command for the models plugin that would export a definitions.yaml
that contains all the model definitions in a Swagger compatible #/definitions
namespace including transformed local JSON references, but only as export functionality. The exported file then could be just ref'd from a Swagger API definition.
The plugin is designed to work the standard Serverless way, so that s-function.json
contains the endpoint definitions and every function is the owner of its endpoints (and also its models). Completely using a separate Swagger API definition would remove this ownership and coupling of function and endpoint deployment.
IMHO the first step more towards a Swagger integration than a Swagger export functionality would be to integrate this plugin into Serverless core. As soon as there is model support in there, the export plugin could just make use of the models. Then the export functionality would be where it logically belongs - in the Swagger export plugin.
from serverless-models-plugin.
After deeper analysis I think the cleanest solution, that would solve the problems at the right places would be:
(1) Integrate the models plugin into Serverless core, so that Serverless has model support.
(2) Make use of the models in the swagger-export plugin (now it should have access to the model definitions)
I will discuss that with the Serverless team and the export-plugin owner.
@eahefnawy @ac360 @kennu What do you think?
from serverless-models-plugin.
It sounds good. In my projects, the master source of data models has often been e.g. Sequelize models. It would be nice to either generate API GW models from them, or the other way round, but I don't know if it's really feasible.
from serverless-models-plugin.
When integrating into core, I would add a S.Project.getModels() and S.Models.addModel(), S.Models.removeModel() and S.Models.setModel() method that your plugin can use to retrieve or store models. Then the function deploy would use them as is with the current models plugin and the export plugin can just grab them and export them in any format.
from serverless-models-plugin.
Oh, wow, a more involved response than I could have hoped for. Thank you both for digging into this with me.
I may be trying to hard to retrofit components from my previous experiences onto Serverless, I cannot be sure; it is very difficult (for me) to make good decisions while being so new to a new framework. Perhaps I should abandon my ambitions of holding onto Swagger, or maybe its just something Serverless is missing and I should be part of the effort to bring it in.
We're looking to migrate a massive application (~300 tables/models) into Lambda, but as 20-50 microservices. Mainly I am struggling to understand what a Serverless workflow would look like in such an effort.
I will keep digging, but appreciate your insight.
Thanks again,
from serverless-models-plugin.
Related Issues (11)
- JSON example HOT 2
- Serverless v1.0 incompatibility HOT 10
- Possible bug / when sls dash deploy in function folder models are not found HOT 2
- updating s-project.json HOT 1
- 'sls models show' not working HOT 4
- Error 'Model not defined: Empty' HOT 5
- Automatically add dependency to package.json HOT 1
- How to retrieve models/schemas in Lambda/Javascript? HOT 9
- model removed from s-models.json is not delete in API Gateway HOT 3
- support multiple s-models.json|yaml files within anywhere of the project's space HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-models-plugin.