There are gems for generating json from Ruby instances (e.g., jbuilder) and gems for building Ruby models from json schemata. Is there one for doing the inverse? That is, for generating a json schema from an existing model?
I would like to go from a model:
class Example
{ firstName: string,
lastName: string,
id: integer }
end
to a schema
{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"id": {
"type": "integer",
}
}
}
This question was asked 6 or so years ago, but never answered: How can I export a rails model to json schema?
I don't know if it's enough for your needs, but there is a gem that does something like that: https://github.com/salesking/json_schema_builder