Code Monkey home page Code Monkey logo

Comments (4)

HyperBrain avatar HyperBrain commented on June 26, 2024

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.

nickchisiu avatar nickchisiu commented on June 26, 2024

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.

HyperBrain avatar HyperBrain commented on June 26, 2024

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.

nickchisiu avatar nickchisiu commented on June 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.