Skip to content
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

Stack overflow on big schema file #85

Closed
apapsch opened this issue Mar 3, 2022 · 2 comments
Closed

Stack overflow on big schema file #85

apapsch opened this issue Mar 3, 2022 · 2 comments

Comments

@apapsch
Copy link

apapsch commented Mar 3, 2022

When feeding schema-generate with a big schema file, it may abort with stack overflow.

Steps to reproduce:

  1. Download this schema file of Shopware Customer. It is ~266 KB big.
  2. The file is missing $schema and $id, I added the following bit (don't know if the schema is correct).
  3. Feed the augmented file to schema-generate and wait.
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://stoplight.io/api/v1/projects/shopware/admin-api/nodes/adminapi.json/components/schemas/Customer"

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.

@apapsch apapsch closed this as completed Jul 1, 2022
@shynome
Copy link

shynome commented Jul 29, 2022

Hi, I have the same problem, how did you deal with it?

@apapsch
Copy link
Author

apapsch commented Jul 29, 2022

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants