swaggest/go-code-builder

OOM trying to generate go from AsyncAPI schema

Closed this issue · 5 comments

I ran into this error using json-cli - but the error points me to this repository.

To reproduce, run the following

json-cli gen-go https://raw.githubusercontent.com/asyncapi/bindings/master/http/json_schemas/operation.json

And you should see

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 266240 bytes) in phar:///usr/local/go/bin/json-cli/vendor/swaggest/go-code-builder/src/GoCodeBuilder.php on line 61

I'm trying to generate an HTTP binding that I can contribute to your go-asyncapi project. I've tried upping the memory limit all the way to 2GB and it still fails. I'm trying to find a fix myself, but I have never even set up a PHP development environment, so if you have any advice or fixes they would be welcome.

For what it's worth, this fails in that repo as well running make gen-2.0.0 after adding the file referenced above as http-operation-binding-object-0.1.0.json and then referencing it in asyncapi-2.0.0.json.

Changes can be seen here

This issue was fixed in https://github.com/swaggest/go-code-builder/releases/tag/v0.4.47, I'll update json-cli with latest version.

There is another issue discovered during AsyncAPI v2.1.0 generation that needs to be fixed: #42. Will have a fix some time soon.

Thanks @vearutop!

Fixed with latest json-cli update. Thanks again!

Yes, but I think it won't work properly still, because of incorrect handling of logical schemas (as in failing test here https://github.com/swaggest/go-asyncapi/pull/10/checks?check_run_id=3456189267). I think I'll have it fixed tomorrow and will upgrade go-asyncapi with latest code generation. Then it should be easier to add new bindings (http) on top.

The go-asyncapi repo should now be ready (updated with latest json-cli and new spec version) for new binding classes.