-
Notifications
You must be signed in to change notification settings - Fork 476
Representers #413
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
Representers #413
Conversation
Also related: This allows to create gem with custom model parsers, like |
end | ||
|
||
if defined?(::Representable) | ||
GrapeSwagger.register_model_parser(GrapeSwagger::Models::Representable, ::Representable::Decorator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be more elegant with something like GrapeSwagger.model_parsers.register ...
.
Overall, big 👍 on this. Looking forward to seeing this finished. We could take grape-entity and representable parts out of grape-swagger altogether into separate gems instead of keeping support here or not. |
@dblock im add model parsers collection, but many specs uses grape entities in test. I create two gems:
Should i publish this gems before this merged? |
I think you should and make it very clear in UPGRADING in grape-swagger what users are supposed to do if they use one or the other. I would move specific tests into those projects and leave some basic tests that work for either library in this PR. You could also have a |
We don't have to, but if you would like to move grape-swagger-* into the ruby-grape organization we can do that too. I can make you co-maintainer of all three, grape-swagger and those two, lmk. |
ce94702
to
d7d6b1b
Compare
@dblock ok, im agreed. I squash my commits, add some information to readme and update changelog. For specs uses
So, now if this this is not problem, we can move this repos to ruby-grape namespace, and delete git ref from Gemfiles to my |
ah, ok i forgot add |
4c19f5e
to
da93d16
Compare
@@ -7,6 +7,7 @@ | |||
* [#405](https://github.com/ruby-grape/grape-swagger/pull/405), [#403](https://github.com/ruby-grape/grape-swagger/issues/403): Added version support matrix - [@LeFnord](https://github.com/LeFnord). | |||
* [#408](https://github.com/ruby-grape/grape-swagger/pull/408): Added support for `HEAD` endpoints - [@Bugagazavr](https://github.com/Bugagazavr). | |||
* [#408](https://github.com/ruby-grape/grape-swagger/pull/411): Added support for `OPTIONS` endpoints - [@Bugagazavr](https://github.com/Bugagazavr). | |||
* [#413](https://github.com/ruby-grape/grape-swagger/pull/413): Move all model parsing logic to separate gems `grape-swagger-entity` and added representable parser `grape-swagger` - [@Bugagazavr](https://github.com/Bugagazavr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a period at the end :)
This is very close, see my smallish comments. I don't think we should treat grape-entity as "default" in specs basically. In the end travis would run general specs for many versions of Ruby and only once against each entity library on top of the latest ruby version or something like that. |
I'm going to cut a release of grape-swagger with whatever changes we have on HEAD now FYI, that should give us more time to announce/release this big change. |
@@ -46,7 +58,7 @@ grape-swagger | swagger spec | grape | grape-entity | |||
0.10.5 | 1.2 | >= 0.10.0 ... <= 0.14.0 | < 0.5.0 | |||
0.11.0 | 1.2 | >= 0.16.2 | < 0.5.0 | |||
0.20.1 | 2.0 | >= 0.12.0 ... <= 0.14.0 | <= 0.5.1 | |||
0.20.3 (next) | 2.0 | >= 0.12.0 ... <= 0.16.2 | <= 0.5.1 | |||
0.21.0 (next) | 2.0 | >= 0.12.0 ... <= 0.16.2 | <= 0.5.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a column here for representable.
1ecfd6b
to
e6934df
Compare
78f395f
to
9942e12
Compare
Ok, i create a simple mock shared example to launch tests without any entity library, and add 2 shared examples to tests grape-swagger with representable and grape-entity. If all ok, i squash my commits into one. |
gem 'grape-swagger-representable' | ||
``` | ||
|
||
##### Custom model parser interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make capitalization consistent, just "Custom Model Parsers"
I made a bunch of nitpick comments in README. Could you please update https://github.com/ruby-grape/grape-swagger/blob/master/UPGRADING.md? Squash, I'll merge. Thanks for the excellent work. |
@dblock done |
Fix the build pls. |
@@ -8,3 +8,5 @@ when 'HEAD' | |||
else | |||
gem 'grape', version | |||
end | |||
|
|||
gem ENV['MODEL_PARSER'], github: "bugagazavr/#{ENV['MODEL_PARSER']}" if ENV.key?('MODEL_PARSER') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets move the "bugagazavr/" part into the ENV variable?
Will hit merge on 💚. |
I see #415, this is cool, I'll just merge and deal with it. |
Feel free to address any of my minor comments in a future PR. You should e-mail the grape mailing list about this change asking people to give it a shot. |
Also release the representer libraries and change the MODEL_PARSER env to the gem name instead of a github reference. |
Thanks 👍 https://rubygems.org/gems/grape-swagger-entity What about move this gems to |
@Bugagazavr lets do it offline |
@Bugagazavr email me dblock at dblock dot org |
This PR contains:
GrapeSwagger.register_model_parser
TODO: