rawmodel/framework

Docs request: please add example for creating model defs directly from JSON schema

prometheas opened this issue · 2 comments

Hey there! I see from the monorepo's primary README that there exists a @rawmodel/schema package, which is described as "JSON Schema Utils" (at the bottom of that same README).

Assuming I'm correct in understanding that this package allows for the direct use of a JSON schema object to be used as a source for model class definition, it would be super handy to have sample code for this use case included to at least the @rawmodel/schema package's local README file.

But I guess first things first: is my understanding about the purpose of this package indeed accurate?

As described by the documentation:

JSON Schema is a pretty popular standard for describing JSON objects. It's sufficient for general use cases, but it's not powerful enough to cover all RawModel features. RawModel provides its own schema syntax which allows for the creation of generic models from a JSON definition.

You can find out more by looking at the test case.

You won't be able to work with JSON Schema directly but you will have to translate it to RawModel's schema. What we usually do on our projects is a limited JSON Schema from where we can easily parse data to a custom format. The reason for this is that JSON Schema can get very complex and supporting all kinds of imports and partials is almost impossible. Check this example schema to get an idea.

OK, I've submitted a very tiny PR that seeks to disambiguate that matter. My confusion arose from the fact that the package is billed as "JSON Schema" utils, which—despite that other tidbit, way up in the README, unfortunately collides with a very well-known community standard name.