Closed beauby closed 6 years ago
Hi @beauby, As i'm in an effort to move from Rails I already changed from Hanami to Padrino. So I can't really test it.
Will jsonapi-rb do something similar to padrino?
@jnylen No worries. What do you mean by "similar to padrino"? (AFAIK padrino is a web framework, while jsonapi-rb is just a library to build JSON API documents – you can use both together.)
@beauby, I mean so it hooks in a bit better, like generators etc. Such as jsonapi-rails, jsonapi-hanami.
I.e.: http://www.rubydoc.info/github/padrino/padrino-framework/Padrino/Generators
@jnylen Oh integrations, yeah, that's something I'm interested in, though my current efforts are focused on the base gems and jsonapi-rails. PRs welcome though :)
I've just tried this branch with Hanami and although the initial error is fixed I get the following:
NameError: uninitialized constant SerializableArea
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/resource_builder.rb:14:in `block in <class:ResourceBuilder>'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/resource_builder.rb:54:in `serializable_class'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/resource_builder.rb:34:in `initialize'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/resource_builder.rb:22:in `new'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/resource_builder.rb:22:in `block in build'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/resource_builder.rb:22:in `map'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/resource_builder.rb:22:in `build'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/renderer.rb:37:in `jsonapi_resources'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/renderer.rb:24:in `render'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.1.3/lib/jsonapi/serializable/renderer.rb:8:in `render'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/bundler/gems/jsonapi-hanami-2a74e0ed8c37/lib/jsonapi/hanami/rendering.rb:28:in `_jsonapi_render_success'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/bundler/gems/jsonapi-hanami-2a74e0ed8c37/lib/jsonapi/hanami/rendering.rb:21:in `_jsonapi_render'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/bundler/gems/jsonapi-hanami-2a74e0ed8c37/lib/jsonapi/hanami/rendering.rb:12:in `block (2 levels) in included'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-utils-1.1.1/lib/hanami/utils/callbacks.rb:246:in `instance_exec'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-utils-1.1.1/lib/hanami/utils/callbacks.rb:246:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-utils-1.1.1/lib/hanami/utils/callbacks.rb:147:in `block in run'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-utils-1.1.1/lib/hanami/utils/callbacks.rb:146:in `each'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-utils-1.1.1/lib/hanami/utils/callbacks.rb:146:in `run'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-controller-1.1.1/lib/hanami/action/callbacks.rb:209:in `_run_after_callbacks'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-controller-1.1.1/lib/hanami/action/callbacks.rb:196:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-controller-1.1.1/lib/hanami/action/callable.rb:71:in `block in call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-controller-1.1.1/lib/hanami/action/throwable.rb:145:in `block in _rescue'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-controller-1.1.1/lib/hanami/action/throwable.rb:143:in `catch'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-controller-1.1.1/lib/hanami/action/throwable.rb:143:in `_rescue'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-controller-1.1.1/lib/hanami/action/callable.rb:67:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-router-1.1.0/lib/hanami/routing/endpoint.rb:101:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/http_router-0.11.2/lib/http_router.rb:193:in `process_destination_path'
(eval):21:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/http_router-0.11.2/lib/http_router.rb:288:in `raw_call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-router-1.1.0/lib/hanami/routing/http_router.rb:156:in `raw_call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/http_router-0.11.2/lib/http_router.rb:142:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-router-1.1.0/lib/hanami/router.rb:1019:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/rack-2.0.3/lib/rack/builder.rb:153:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-1.1.0/lib/hanami/middleware.rb:52:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-1.1.0/lib/hanami/application.rb:169:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/2.5.0/delegate.rb:83:in `method_missing'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/http_router-0.11.2/lib/http_router.rb:193:in `process_destination_path'
(eval):18:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/http_router-0.11.2/lib/http_router.rb:288:in `raw_call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-router-1.1.0/lib/hanami/routing/http_router.rb:156:in `raw_call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/http_router-0.11.2/lib/http_router.rb:142:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-router-1.1.0/lib/hanami/router.rb:1019:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/rack-2.0.3/lib/rack/method_override.rb:22:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-1.1.0/lib/hanami/assets/static.rb:49:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/rack-2.0.3/lib/rack/content_length.rb:15:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/rack-2.0.3/lib/rack/common_logger.rb:33:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/rack-2.0.3/lib/rack/builder.rb:153:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-1.1.0/lib/hanami/app.rb:42:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:86:in `proceed_as_child'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:31:in `call!'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:18:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/hanami-1.1.0/lib/hanami/assets/static.rb:49:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/rack-2.0.3/lib/rack/lint.rb:49:in `_call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/rack-2.0.3/lib/rack/lint.rb:37:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/rack-2.0.3/lib/rack/show_exceptions.rb:23:in `call'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/gems/2.5.0/gems/rack-2.0.3/lib/rack/handler/webrick.rb:86:in `service'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/2.5.0/webrick/httpserver.rb:140:in `service'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/2.5.0/webrick/httpserver.rb:96:in `run'
/home/ant/.rbenv/versions/2.5.0-preview1/lib/ruby/2.5.0/webrick/server.rb:288:in `block in start_thread'```
@ArayB It seems you are attempting to serialize an instance of Area
but haven't defined a corresponding serializer. Is that right?
Well that's fairly embarrassing!
That would be correct.
No worries – I admit the documentation is a bit lacking.
Once I created the serializer the controller responded with the json as expected. So it seems to be fixed.
If I make some time I'll try and update some documentation around the serializer as well.
Fixes #8.
/cc @jnylen – could you give this branch a try (with a
$ bundle update
to ensure the jsonapi-* deps are pinned to the right versions)?