Skip to content

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

Merged
merged 1 commit into from
May 10, 2016
Merged

Representers #413

merged 1 commit into from
May 10, 2016

Conversation

kzaitsev
Copy link
Contributor

@kzaitsev kzaitsev commented May 7, 2016

This PR contains:

  • allow to attach custom model parser via GrapeSwagger.register_model_parser
  • trailblazer representers support
  • model parsers moved to separated classes
  • grape-entity not a runtime dependency

TODO:

  • changelog
  • update README

@kzaitsev
Copy link
Contributor Author

kzaitsev commented May 7, 2016

Also related:

This allows to create gem with custom model parsers, like representable, roar, grape-entity, activemodel-serializer, virtus-model

https://github.com/Bugagazavr/grape-swagger-representable

@dblock

end

if defined?(::Representable)
GrapeSwagger.register_model_parser(GrapeSwagger::Models::Representable, ::Representable::Decorator)
Copy link
Member

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

@dblock
Copy link
Member

dblock commented May 7, 2016

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.

@kzaitsev
Copy link
Contributor Author

kzaitsev commented May 7, 2016

@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?

@dblock
Copy link
Member

dblock commented May 8, 2016

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 .travis.yml that sets something like ENTITY_LIBRARY and runs "integration" tests with it, a little bit how https://github.com/dblock/slack-ruby-client for example switches between faye-websocket and celluloid to test.

@dblock
Copy link
Member

dblock commented May 8, 2016

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.

@kzaitsev kzaitsev force-pushed the representers branch 3 times, most recently from ce94702 to d7d6b1b Compare May 8, 2016 01:48
@kzaitsev
Copy link
Contributor Author

kzaitsev commented May 8, 2016

@dblock ok, im agreed.

I squash my commits, add some information to readme and update changelog.

For specs uses grape-swagger-entity

.travis.yml also updated in https://github.com/Bugagazavr/grape-swagger-representable and https://github.com/Bugagazavr/grape-swagger-entity

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 grape-swagger and add dependencies to gempecs

@kzaitsev
Copy link
Contributor Author

kzaitsev commented May 8, 2016

ah, ok i forgot add ENTITY_LIBRARY, take a moment i add this

@kzaitsev kzaitsev force-pushed the representers branch 4 times, most recently from 4c19f5e to da93d16 Compare May 8, 2016 12:12
@@ -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)
Copy link
Member

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

@dblock
Copy link
Member

dblock commented May 9, 2016

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.

@dblock
Copy link
Member

dblock commented May 9, 2016

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
Copy link
Member

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.

@kzaitsev kzaitsev force-pushed the representers branch 4 times, most recently from 1ecfd6b to e6934df Compare May 9, 2016 16:17
@kzaitsev kzaitsev force-pushed the representers branch 2 times, most recently from 78f395f to 9942e12 Compare May 9, 2016 16:19
@kzaitsev
Copy link
Contributor Author

kzaitsev commented May 9, 2016

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
Copy link
Member

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"

@dblock
Copy link
Member

dblock commented May 10, 2016

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.

@kzaitsev
Copy link
Contributor Author

@dblock done

@dblock
Copy link
Member

dblock commented May 10, 2016

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')
Copy link
Member

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?

@dblock
Copy link
Member

dblock commented May 10, 2016

Will hit merge on 💚.

@dblock
Copy link
Member

dblock commented May 10, 2016

I see #415, this is cool, I'll just merge and deal with it.

@dblock dblock merged commit 70a31d3 into ruby-grape:master May 10, 2016
@dblock
Copy link
Member

dblock commented May 10, 2016

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.

@dblock
Copy link
Member

dblock commented May 10, 2016

Also release the representer libraries and change the MODEL_PARSER env to the gem name instead of a github reference.

@kzaitsev
Copy link
Contributor Author

Thanks 👍

https://rubygems.org/gems/grape-swagger-entity
https://rubygems.org/gems/grape-swagger-representable

What about move this gems to ruby-grape org?

@dblock
Copy link
Member

dblock commented May 11, 2016

@Bugagazavr lets do it offline

@dblock
Copy link
Member

dblock commented May 11, 2016

@Bugagazavr email me dblock at dblock dot org

LeFnord pushed a commit to LeFnord/grape-swagger that referenced this pull request Feb 9, 2019
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

Successfully merging this pull request may close these issues.

3 participants