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

Parameters accept a value option for fixed values. #369

Merged
merged 1 commit into from
Jan 24, 2018
Merged

Parameters accept a value option for fixed values. #369

merged 1 commit into from
Jan 24, 2018

Conversation

jsmestad
Copy link
Contributor

@jsmestad jsmestad commented Jan 22, 2018

Background

When building out a JSONAPI, every endpoint has a type field with a fixed value of the resources name. Writing parameter :type, 'The object type', value: 'users' is more clear of it's static nature than looking for a let.

More broadly, when using rspec_api_documentation for 10-15 projects now. Having let reserved for dynamic values and using value: 3 for things that are static, seems to reduce the "noise" in writing larger spec files.

Need Feedback

Not 100% sure on the value: naming convention. I also tried having method support a block (like method: -> { '3' }), but that did not feel right.

Notes

  • The specs suite does not seem to like Ruby 2.5.0 with the current Gemfile.lock. I suggest removing the Gemfile.lock from the repo (gitignore it) and depend on the gemspec.
  • I had to upgrade the json gem in order to run bundle on Ruby 2.5 / OSX 10.13

This is very common in JSONAPI, where the `type` field is a fixed value
of the resource name.

Having fixed values supported makes the API more clear and uses `let`
for dynamic values that need to be evaluated.
@oestrich oestrich merged commit 8f6c458 into zipmark:master Jan 24, 2018
@oestrich
Copy link
Contributor

Thanks!

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.

2 participants