Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
880 views
in Technique[技术] by (71.8m points)

architecture - How to manage JSON-Schemas for multiple projects?

Suppose you have a Schema that is used in a UI-App (e.g. Vue), a Node.js or Springboot Server and has to validate against Databases (e.g. SQL, mongoDB,...), and maybe some Micro-services running on whatever.

How and where do I manage a this JSON-Schema, so that if I have to change the schema for whatever Reason, that every architectural component can handle the new JSON-Schema(s). Otherwise I need to update the Schema in up to 10 projects so none is incompatible.

Is it really as simple as having a git project full with just JSON-Schemas or do I need specific loaders for each language/environment? Are there best practices that I am unaware of?

PS: I don't really think I need the automatically synchronized on runtime, so don't really think I need another Microservice to achieve that. That being said, if a Microservice is the best way to go, then getting a Microservice it is.

question from:https://stackoverflow.com/questions/65944643/how-to-manage-json-schemas-for-multiple-projects

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you keep them in a git project, how do you load them? Clone the project each time the app starts? It may work, but I would go with a more flexible approach that should take too much effort to be done:

  • Build a JSON schema repository accessible via a REST API
  • When the app starts, it makes a request to grab the schema (latest, or a specific version)

That way you get an uniform (and scalable) way of playing with the schemas. Even if you think about a hot-reload sometime in the future, you can leverage this approach to do that.

Here is an old project in this direction, you may give it a shot to see if it works (or for some inspiration, at least)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...