-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic ADT generation from JSON Schema docs? #2137
Comments
It's a very nice feature request. Been thinking about it for a while myself. There are many many applications that would benefit. |
It doesn't seem like a ton of work so I might take a crack at it. I could use some guidance. I'm thinking of taking the code generation approach, but maybe there are others? I can imagine just dynamically loading the schema into in-memory ADTs perhaps, but I'm not sure if that sort of mechanism is exposed. Is there some prior art I can look at for doing generation of Rascal code? Kind of a tricky thing to search for :) |
Cool! Steps could be:
All this under the assumption that readJSON is perfect as it is. Which is probably not the case. But it's good to minimize changes there, since read/write JSON semantics is a contract for many Rascal applications; including the LSP and VScode. Remember that JSON is a serialization format and not an expression language. For example integers have no binary bounds. What do you think of the above? |
If you look in the Type module you will find the Production adt which has a If you use the type reification operator on an existing definition then you can get examples of the target format you are converting to; try |
Hi there, new Rascal user, just kicking the tires. 👋
I'm wondering if it would be easy/possible/palatable to add some feature to the Rascal stdlib to generate ADT code given a JSON Schema. I don't know Rascal nor JSON Schema super well, but they seem to map pretty closely.
My use case is that I'm sketching a DSL for Github Workflows that's a little nicer to work with versus their YAML representation. Right now, I'm using
lang::yaml::Model
to source-to-source transform my DSL ADTs into YAML, and thendumpYAML
ing into files. I was thinking I could also write an ADT that is closer to the YAML representation, and transform into that, which would then transform tolang::yaml::Model
. There's already a JSON Schema for workflows and it would be nice if it I could just generate ADTs from it.Just an idea!
The text was updated successfully, but these errors were encountered: