Comments (4)
A feasible solution is to extend the JSON refs that currently only allow referencing to local models, so that files or even remote references can be specified.
This is an easy change as the file and remote references just have been disabled and have to be turned on in the options of the json-ref module.
Example
...
"properties":
"mySubModel1":
"$ref": "./models/mysubmodel.yaml"
"mySubModel2":
"$ref": "https://mymodelrepository.company.com/mysubmodel2.yaml"
...
from serverless-models-plugin.
yes, that's a nice solution for referring models outside of the current file . But for example if you want to maintain 2 or more different s-models.json|yaml files without even having the refs usage there , it would be something like :
functions
└── v1
└── auth
└── register
└── POST
├── event.json
├── handler.js
├── s-function.json
└── s-models.json
└── login
└── POST
├── event.json
├── handler.js
├── s-function.json
└── s-models.json
I implemented something similar with this with Swagger models for a customer, so the final solution was on having one single big models object builded from multiple models files and this way you can reference anything from a file to another because the models are merged in that single object and they have direct access to each other . I'll try to do a quick implementation for that to prove my intentions.
from serverless-models-plugin.
Ok, agree. IMHO the new version should have both variants included.
What you mentioned follows the same semantic like the s-template.json
files. So that the models are merged on deploy. The only pitfall would be that you have the same model defined in two adjacent levels. The deploy must therefore load all models even on a single function deploy, as the model definitions are global per AWS API and bail out with an error if such inconsistencies are encountered as subsequent deploys would break the existing already uploaded models in that case.
from serverless-models-plugin.
yep, true. It could be added a sanity check feature there and throw an error if there are duplicate models names on different files, so this way models are not getting unconsciously overwritten. For the issue with updating only the modified models I would suggest some more generic implementation like a sync/caching feature , I'm trying to think best "generic" I can with the new upcoming support for multiple microservices providers like Azure, Google Cloud , etc . and having compatible features with the most of those.
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
- Questions about Swagger compatibility and implications. HOT 6
- 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
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.