vuex-orm icon indicating copy to clipboard operation
vuex-orm copied to clipboard

generate vuex-orm models based on json schema

Open yeus opened this issue 5 years ago • 3 comments
trafficstars

Is your feature request related to a problem? Please describe...

Some servers implement a description of the models employed by the API using json-schema and Standards developed by "OpenAPI"-project:

  • Json-Schema: http://json-schema.org/
  • OpenAPI: https://swagger.io/specification/

This library here gen generate APIs in multiple languages:

https://github.com/OpenAPITools/openapi-generator

As an example, the framework "FastAPI" which is used for generating REST-APIs automatically generates the json schema based on the models defined. This json schema could easily be taken in order to generate models for vuex-orm. In the case of FastAPI the json schema is also embedded in the API itself and can be requested by clients. So we could even automatically adapt the schema in vuex-orm based on changes in the server.

  • https://fastapi.tiangolo.com/features/#fastapi-features

Describe the solution you'd like

A function which creates models for Vuex-ORM based on a json schema.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered. Out-of-the-box javscript solutions such as:

https://www.npmjs.com/package/jsonschema

But I am not sure how easy it is to integrate that with vuex-orm.

EDIT: update links

yeus avatar Oct 07 '20 12:10 yeus

This would be a killer feature for sure. Without it, one must maintain the models (schemas) both on client and server manually.

PetrPy avatar May 20 '21 20:05 PetrPy

@yeus @PetrPy I'm in the early stages of planning a proof of concept for this: https://github.com/Truemedia/vuex-orm-jsonschema

Will post updates here once I make some progress in my free time

Truemedia avatar Jun 08 '21 18:06 Truemedia

Just saw this thread. I'm also using JSON Schema with Ajv. See #759 for some sample code.

semiaddict avatar Dec 08 '21 13:12 semiaddict