Closed apapsch closed 2 years ago
Hi, I have the same problem, how did you deal with it?
This repo seems to be abandoned and I didn't want to dig into the code, architectural problems are hard to fix when you don't know the code. In the end I created a POC that sufficed for my need generating Go structs of Shopware schema file. I just extracted and dumped it here: https://codeberg.org/apapsch/go-jsonschema-model-gen Feel free to fork and adapt to your needs. It creates structs from the toplevel entity and any referenced entities.
In the Shopware case, I had to search-replace some mishaps in the generated code, but that was due to the schema being invalid itself: for collection fields they specify object
where it should really be array of T
(I guess it was due to them implementing collections in PHP using custom classes, which their schema generator didn't recognize as array of T
).
When feeding
schema-generate
with a big schema file, it may abort with stack overflow.Steps to reproduce:
$schema
and$id
, I added the following bit (don't know if the schema is correct).schema-generate
and wait.Result
The program aborts: overflow.log.
schema-generate
was built with go version go1.17.6 windows/amd64.Expected Result
schema-generate
does not crash, though it might exit with another error because I don't know if the example schema file is valid.