grape 0.1.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +1167 -0
- data/CONTRIBUTING.md +156 -0
- data/LICENSE +1 -1
- data/README.md +4192 -0
- data/UPGRADING.md +1697 -0
- data/grape.gemspec +28 -105
- data/grape.png +0 -0
- data/lib/grape/api/helpers.rb +9 -0
- data/lib/grape/api/instance.rb +247 -0
- data/lib/grape/api.rb +158 -194
- data/lib/grape/content_types.rb +31 -0
- data/lib/grape/cookies.rb +50 -0
- data/lib/grape/dry_types.rb +10 -0
- data/lib/grape/dsl/api.rb +17 -0
- data/lib/grape/dsl/callbacks.rb +69 -0
- data/lib/grape/dsl/configuration.rb +15 -0
- data/lib/grape/dsl/desc.rb +124 -0
- data/lib/grape/dsl/headers.rb +21 -0
- data/lib/grape/dsl/helpers.rb +108 -0
- data/lib/grape/dsl/inside_route.rb +454 -0
- data/lib/grape/dsl/logger.rb +22 -0
- data/lib/grape/dsl/middleware.rb +54 -0
- data/lib/grape/dsl/parameters.rb +266 -0
- data/lib/grape/dsl/request_response.rb +171 -0
- data/lib/grape/dsl/routing.rb +248 -0
- data/lib/grape/dsl/settings.rb +179 -0
- data/lib/grape/dsl/validations.rb +57 -0
- data/lib/grape/endpoint.rb +398 -68
- data/lib/grape/env.rb +20 -0
- data/lib/grape/error_formatter/base.rb +68 -0
- data/lib/grape/error_formatter/json.rb +28 -0
- data/lib/grape/error_formatter/serializable_hash.rb +7 -0
- data/lib/grape/error_formatter/txt.rb +21 -0
- data/lib/grape/error_formatter/xml.rb +11 -0
- data/lib/grape/error_formatter.rb +15 -0
- data/lib/grape/exceptions/base.rb +76 -0
- data/lib/grape/exceptions/conflicting_types.rb +11 -0
- data/lib/grape/exceptions/empty_message_body.rb +11 -0
- data/lib/grape/exceptions/incompatible_option_values.rb +11 -0
- data/lib/grape/exceptions/invalid_accept_header.rb +11 -0
- data/lib/grape/exceptions/invalid_formatter.rb +11 -0
- data/lib/grape/exceptions/invalid_message_body.rb +11 -0
- data/lib/grape/exceptions/invalid_parameters.rb +11 -0
- data/lib/grape/exceptions/invalid_response.rb +11 -0
- data/lib/grape/exceptions/invalid_version_header.rb +11 -0
- data/lib/grape/exceptions/invalid_versioner_option.rb +11 -0
- data/lib/grape/exceptions/invalid_with_option_for_represent.rb +11 -0
- data/lib/grape/exceptions/method_not_allowed.rb +11 -0
- data/lib/grape/exceptions/missing_group_type.rb +13 -0
- data/lib/grape/exceptions/missing_mime_type.rb +11 -0
- data/lib/grape/exceptions/missing_option.rb +11 -0
- data/lib/grape/exceptions/missing_vendor_option.rb +11 -0
- data/lib/grape/exceptions/too_deep_parameters.rb +11 -0
- data/lib/grape/exceptions/too_many_multipart_files.rb +11 -0
- data/lib/grape/exceptions/unknown_auth_strategy.rb +11 -0
- data/lib/grape/exceptions/unknown_options.rb +11 -0
- data/lib/grape/exceptions/unknown_parameter.rb +11 -0
- data/lib/grape/exceptions/unknown_params_builder.rb +11 -0
- data/lib/grape/exceptions/unknown_validator.rb +11 -0
- data/lib/grape/exceptions/unsupported_group_type.rb +13 -0
- data/lib/grape/exceptions/validation.rb +25 -0
- data/lib/grape/exceptions/validation_array_errors.rb +14 -0
- data/lib/grape/exceptions/validation_errors.rb +53 -0
- data/lib/grape/extensions/active_support/hash_with_indifferent_access.rb +24 -0
- data/lib/grape/extensions/hash.rb +27 -0
- data/lib/grape/extensions/hashie/mash.rb +24 -0
- data/lib/grape/formatter/base.rb +16 -0
- data/lib/grape/formatter/json.rb +13 -0
- data/lib/grape/formatter/serializable_hash.rb +39 -0
- data/lib/grape/formatter/txt.rb +11 -0
- data/lib/grape/formatter/xml.rb +13 -0
- data/lib/grape/formatter.rb +17 -0
- data/lib/grape/json.rb +10 -0
- data/lib/grape/locale/en.yml +59 -0
- data/lib/grape/middleware/auth/base.rb +23 -0
- data/lib/grape/middleware/auth/dsl.rb +39 -0
- data/lib/grape/middleware/auth/strategies.rb +25 -0
- data/lib/grape/middleware/auth/strategy_info.rb +15 -0
- data/lib/grape/middleware/base.rb +89 -18
- data/lib/grape/middleware/error.rb +129 -10
- data/lib/grape/middleware/filter.rb +19 -0
- data/lib/grape/middleware/formatter.rb +124 -82
- data/lib/grape/middleware/globals.rb +14 -0
- data/lib/grape/middleware/stack.rb +109 -0
- data/lib/grape/middleware/versioner/accept_version_header.rb +38 -0
- data/lib/grape/middleware/versioner/base.rb +74 -0
- data/lib/grape/middleware/versioner/header.rb +127 -0
- data/lib/grape/middleware/versioner/param.rb +32 -0
- data/lib/grape/middleware/versioner/path.rb +40 -0
- data/lib/grape/middleware/versioner.rb +21 -21
- data/lib/grape/namespace.rb +46 -0
- data/lib/grape/params_builder/base.rb +18 -0
- data/lib/grape/params_builder/hash.rb +11 -0
- data/lib/grape/params_builder/hash_with_indifferent_access.rb +11 -0
- data/lib/grape/params_builder/hashie_mash.rb +11 -0
- data/lib/grape/params_builder.rb +32 -0
- data/lib/grape/parser/base.rb +16 -0
- data/lib/grape/parser/json.rb +14 -0
- data/lib/grape/parser/xml.rb +14 -0
- data/lib/grape/parser.rb +15 -0
- data/lib/grape/path.rb +76 -0
- data/lib/grape/presenters/presenter.rb +11 -0
- data/lib/grape/railtie.rb +9 -0
- data/lib/grape/request.rb +190 -0
- data/lib/grape/router/base_route.rb +39 -0
- data/lib/grape/router/greedy_route.rb +20 -0
- data/lib/grape/router/pattern.rb +81 -0
- data/lib/grape/router/route.rb +62 -0
- data/lib/grape/router.rb +190 -0
- data/lib/grape/serve_stream/file_body.rb +36 -0
- data/lib/grape/serve_stream/sendfile_response.rb +21 -0
- data/lib/grape/serve_stream/stream_response.rb +23 -0
- data/lib/grape/types/invalid_value.rb +8 -0
- data/lib/grape/util/base_inheritable.rb +43 -0
- data/lib/grape/util/cache.rb +17 -0
- data/lib/grape/util/endpoint_configuration.rb +8 -0
- data/lib/grape/util/header.rb +13 -0
- data/lib/grape/util/inheritable_setting.rb +100 -0
- data/lib/grape/util/inheritable_values.rb +29 -0
- data/lib/grape/util/lazy/block.rb +29 -0
- data/lib/grape/util/lazy/value.rb +38 -0
- data/lib/grape/util/lazy/value_array.rb +21 -0
- data/lib/grape/util/lazy/value_enumerable.rb +34 -0
- data/lib/grape/util/lazy/value_hash.rb +21 -0
- data/lib/grape/util/media_type.rb +70 -0
- data/lib/grape/util/registry.rb +27 -0
- data/lib/grape/util/reverse_stackable_values.rb +15 -0
- data/lib/grape/util/stackable_values.rb +36 -0
- data/lib/grape/util/strict_hash_configuration.rb +108 -0
- data/lib/grape/validations/attributes_doc.rb +60 -0
- data/lib/grape/validations/attributes_iterator.rb +62 -0
- data/lib/grape/validations/contract_scope.rb +34 -0
- data/lib/grape/validations/multiple_attributes_iterator.rb +13 -0
- data/lib/grape/validations/params_scope.rb +538 -0
- data/lib/grape/validations/single_attribute_iterator.rb +26 -0
- data/lib/grape/validations/types/array_coercer.rb +61 -0
- data/lib/grape/validations/types/custom_type_coercer.rb +164 -0
- data/lib/grape/validations/types/custom_type_collection_coercer.rb +56 -0
- data/lib/grape/validations/types/dry_type_coercer.rb +66 -0
- data/lib/grape/validations/types/file.rb +31 -0
- data/lib/grape/validations/types/invalid_value.rb +17 -0
- data/lib/grape/validations/types/json.rb +71 -0
- data/lib/grape/validations/types/multiple_type_coercer.rb +57 -0
- data/lib/grape/validations/types/primitive_coercer.rb +73 -0
- data/lib/grape/validations/types/set_coercer.rb +35 -0
- data/lib/grape/validations/types/variant_collection_coercer.rb +51 -0
- data/lib/grape/validations/types.rb +213 -0
- data/lib/grape/validations/validator_factory.rb +15 -0
- data/lib/grape/validations/validators/all_or_none_of_validator.rb +16 -0
- data/lib/grape/validations/validators/allow_blank_validator.rb +20 -0
- data/lib/grape/validations/validators/as_validator.rb +14 -0
- data/lib/grape/validations/validators/at_least_one_of_validator.rb +15 -0
- data/lib/grape/validations/validators/base.rb +88 -0
- data/lib/grape/validations/validators/coerce_validator.rb +75 -0
- data/lib/grape/validations/validators/contract_scope_validator.rb +41 -0
- data/lib/grape/validations/validators/default_validator.rb +37 -0
- data/lib/grape/validations/validators/exactly_one_of_validator.rb +17 -0
- data/lib/grape/validations/validators/except_values_validator.rb +24 -0
- data/lib/grape/validations/validators/length_validator.rb +49 -0
- data/lib/grape/validations/validators/multiple_params_base.rb +34 -0
- data/lib/grape/validations/validators/mutual_exclusion_validator.rb +16 -0
- data/lib/grape/validations/validators/presence_validator.rb +15 -0
- data/lib/grape/validations/validators/regexp_validator.rb +16 -0
- data/lib/grape/validations/validators/same_as_validator.rb +29 -0
- data/lib/grape/validations/validators/values_validator.rb +60 -0
- data/lib/grape/validations.rb +21 -0
- data/lib/grape/version.rb +6 -0
- data/lib/grape/xml.rb +10 -0
- data/lib/grape.rb +81 -17
- metadata +250 -192
- data/.document +0 -5
- data/.gitignore +0 -23
- data/.rspec +0 -2
- data/.rvmrc +0 -1
- data/Gemfile +0 -21
- data/Gemfile.lock +0 -58
- data/README.markdown +0 -75
- data/Rakefile +0 -70
- data/VERSION +0 -1
- data/autotest/discover.rb +0 -1
- data/lib/grape/middleware/auth/basic.rb +0 -30
- data/lib/grape/middleware/auth/oauth2.rb +0 -55
- data/lib/grape/middleware/prefixer.rb +0 -21
- data/lib/grape/middleware_stack.rb +0 -35
- data/spec/grape/api_spec.rb +0 -343
- data/spec/grape/endpoint_spec.rb +0 -104
- data/spec/grape/middleware/auth/basic_spec.rb +0 -31
- data/spec/grape/middleware/auth/oauth2_spec.rb +0 -88
- data/spec/grape/middleware/base_spec.rb +0 -63
- data/spec/grape/middleware/error_spec.rb +0 -49
- data/spec/grape/middleware/formatter_spec.rb +0 -87
- data/spec/grape/middleware/prefixer_spec.rb +0 -30
- data/spec/grape/middleware/versioner_spec.rb +0 -40
- data/spec/grape/middleware_stack_spec.rb +0 -47
- data/spec/grape_spec.rb +0 -1
- data/spec/spec_helper.rb +0 -20
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Contributing to Grape
|
|
2
|
+
=====================
|
|
3
|
+
|
|
4
|
+
Grape is work of [hundreds of contributors](https://github.com/ruby-grape/grape/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/ruby-grape/grape/pulls), [propose features and discuss issues](https://github.com/ruby-grape/grape/issues).
|
|
5
|
+
|
|
6
|
+
#### Fork the Project
|
|
7
|
+
|
|
8
|
+
Fork the [project on Github](https://github.com/ruby-grape/grape) and check out your copy.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
git clone https://github.com/contributor/grape.git
|
|
12
|
+
cd grape
|
|
13
|
+
git remote add upstream https://github.com/ruby-grape/grape.git
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
#### Create a Topic Branch
|
|
17
|
+
|
|
18
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
git checkout master
|
|
22
|
+
git pull upstream master
|
|
23
|
+
git checkout -b my-feature-branch
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Docker
|
|
27
|
+
|
|
28
|
+
If you're familiar with [Docker](https://www.docker.com/), you can run everything through the following command:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
docker-compose run --rm --build grape <command_and_parameters>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
About the execution process:
|
|
35
|
+
- displays Ruby, Rubygems, Bundle and Gemfile version when starting:
|
|
36
|
+
```
|
|
37
|
+
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux-musl]
|
|
38
|
+
rubygems 3.4.12
|
|
39
|
+
Bundler version 2.4.1 (2022-12-24 commit f3175f033c)
|
|
40
|
+
Running default Gemfile
|
|
41
|
+
```
|
|
42
|
+
- keeps the gems to the latest possible version
|
|
43
|
+
- executes under `bundle exec`
|
|
44
|
+
|
|
45
|
+
Here are some examples:
|
|
46
|
+
|
|
47
|
+
- running all specs `docker-compose run --rm --build grape rspec`
|
|
48
|
+
- running rspec on a specific file `docker-compose run --rm --build grape rspec spec/:file_path`
|
|
49
|
+
- running task `docker-compose run --rm --build grape rake <task_name>`
|
|
50
|
+
- running rubocop `docker-compose run --rm --build grape rubocop`
|
|
51
|
+
- running all specs on a specific ruby version (e.g 2.7.7) `RUBY_VERSION=2.7.7 docker-compose run --rm --build grape rspec`
|
|
52
|
+
- running specs on a specific gemfile (e.g rails_7_0.gemfile) `docker-compose run -e GEMFILE=rails_7_0 --rm --build grape rspec`
|
|
53
|
+
|
|
54
|
+
#### Bundle Install and Test
|
|
55
|
+
|
|
56
|
+
Ensure that you can build the project and run tests.
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
bundle install
|
|
60
|
+
bundle exec rake
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Run tests against all supported versions of Rails.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
gem install appraisal
|
|
67
|
+
appraisal install
|
|
68
|
+
appraisal rake spec
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### Write Tests
|
|
72
|
+
|
|
73
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/grape](spec/grape).
|
|
74
|
+
|
|
75
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
|
76
|
+
|
|
77
|
+
#### Write Code
|
|
78
|
+
|
|
79
|
+
Implement your feature or bug fix.
|
|
80
|
+
|
|
81
|
+
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
|
|
82
|
+
|
|
83
|
+
Make sure that `bundle exec rake` completes without errors.
|
|
84
|
+
|
|
85
|
+
#### Write Documentation
|
|
86
|
+
|
|
87
|
+
Document any external behavior in the [README](README.md).
|
|
88
|
+
|
|
89
|
+
You should also document code as necessary, using current code as examples. This project uses [YARD](https://yardoc.org/). You can run and preview the docs locally by [installing `yard`](https://yardoc.org/), running `yard server --reload` and view the docs at http://localhost:8808.
|
|
90
|
+
|
|
91
|
+
#### Update Changelog
|
|
92
|
+
|
|
93
|
+
Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
|
|
94
|
+
|
|
95
|
+
#### Commit Changes
|
|
96
|
+
|
|
97
|
+
Make sure git knows your name and email address:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
git config --global user.name "Your Name"
|
|
101
|
+
git config --global user.email "contributor@example.com"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
git add ...
|
|
108
|
+
git commit
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Push
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
git push origin my-feature-branch
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### Make a Pull Request
|
|
118
|
+
|
|
119
|
+
Go to https://github.com/contributor/grape and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
|
120
|
+
|
|
121
|
+
#### Rebase
|
|
122
|
+
|
|
123
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
git fetch upstream
|
|
127
|
+
git rebase upstream/master
|
|
128
|
+
git push origin my-feature-branch -f
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Update CHANGELOG Again
|
|
132
|
+
|
|
133
|
+
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
* [#123](https://github.com/ruby-grape/grape/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Amend your previous commit and force push the changes.
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
git commit --amend
|
|
143
|
+
git push origin my-feature-branch -f
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Check on Your Pull Request
|
|
147
|
+
|
|
148
|
+
Go back to your pull request after a few minutes and see whether it passed muster with CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
|
149
|
+
|
|
150
|
+
#### Be Patient
|
|
151
|
+
|
|
152
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang in there!
|
|
153
|
+
|
|
154
|
+
#### Thank You
|
|
155
|
+
|
|
156
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/LICENSE
CHANGED