apipie-rails 0.5.19 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +57 -0
  3. data/CHANGELOG.md +40 -0
  4. data/README.rst +25 -5
  5. data/apipie-rails.gemspec +3 -2
  6. data/app/controllers/apipie/apipies_controller.rb +1 -1
  7. data/app/public/apipie/javascripts/bundled/bootstrap-collapse.js +70 -41
  8. data/app/public/apipie/javascripts/bundled/bootstrap.js +1033 -479
  9. data/app/public/apipie/javascripts/bundled/jquery.js +5 -5
  10. data/app/public/apipie/stylesheets/bundled/bootstrap-responsive.min.css +9 -12
  11. data/app/public/apipie/stylesheets/bundled/bootstrap.min.css +9 -689
  12. data/config/locales/ko.yml +31 -0
  13. data/gemfiles/Gemfile.rails50 +10 -0
  14. data/gemfiles/Gemfile.rails51 +10 -0
  15. data/gemfiles/Gemfile.rails52 +10 -0
  16. data/gemfiles/Gemfile.rails60 +17 -0
  17. data/gemfiles/Gemfile.rails61 +17 -0
  18. data/lib/apipie/configuration.rb +8 -3
  19. data/lib/apipie/dsl_definition.rb +12 -1
  20. data/lib/apipie/extractor/recorder.rb +3 -2
  21. data/lib/apipie/param_description.rb +8 -4
  22. data/lib/apipie/static_dispatcher.rb +3 -1
  23. data/lib/apipie/swagger_generator.rb +7 -1
  24. data/lib/apipie/validator.rb +1 -1
  25. data/lib/apipie/version.rb +1 -1
  26. data/lib/apipie-rails.rb +0 -4
  27. data/rel-eng/gem_release.ipynb +41 -9
  28. data/spec/controllers/apipies_controller_spec.rb +25 -0
  29. data/spec/controllers/users_controller_spec.rb +23 -0
  30. data/spec/dummy/app/controllers/users_controller.rb +6 -0
  31. data/spec/dummy/config/application.rb +0 -3
  32. data/spec/dummy/config/environments/development.rb +0 -3
  33. data/spec/dummy/config/environments/production.rb +0 -3
  34. data/spec/dummy/config/environments/test.rb +0 -5
  35. data/spec/lib/file_handler_spec.rb +7 -0
  36. data/spec/lib/param_description_spec.rb +68 -0
  37. data/spec/lib/swagger/rake_swagger_spec.rb +15 -0
  38. data/spec/lib/swagger/response_validation_spec.rb +17 -17
  39. data/spec/spec_helper.rb +7 -1
  40. data/spec/support/rails-42-ruby-26.rb +15 -0
  41. metadata +30 -97
  42. data/.travis.yml +0 -41
  43. data/Gemfile +0 -1
  44. data/Gemfile.rails41 +0 -7
  45. data/Gemfile.rails42 +0 -14
  46. data/Gemfile.rails50 +0 -9
  47. data/Gemfile.rails51 +0 -9
  48. data/Gemfile.rails60 +0 -10
  49. data/Gemfile.rails61 +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 444b1aeccaa322d75d64131d2539ae5ecb9ceb3ea984e02c9cfd17a2c80d1190
4
- data.tar.gz: ddbcdfaee3494a2f35f343a361c9e07b72541b5a75e5e537c0776f8b6c9669e9
3
+ metadata.gz: c7a94176378d53856507d3df6c324e69b2637430e6d627726d344fc427e619a7
4
+ data.tar.gz: 5f00ebcf9cf5fb2940e86681f2fbdb685ed215bf3708ebcc41ab0f34a0f2bab1
5
5
  SHA512:
6
- metadata.gz: 18f5f97fc24bab7aa9c554cd3be305e9bf5eb5266466a79c4484fb0c7f6e4b80912d5ddb224a8ed1dd8d8002c376cd7e30a359ab4f0855d60d404352dc74acb0
7
- data.tar.gz: 1c66c6990ab997d21e727900a4a36648b76aa08357491007821c4a5f1b46b25f8e48fbb9cdeccfd26f20b1ea268c32c6698f73b040226036b0f5f72fc9447060
6
+ metadata.gz: fd4340d9646496246e06454941c93ebae9039d59c0449e5b9683f01aa18cd02414ea0233f0345e09f4b4107f8daeb84387ace0af32b5e2d82cea0f6cbd57a53b
7
+ data.tar.gz: 6abd0665093f3e7c9fd2d9bcf965bf85b2b4bbff937c52b317c4601898e6a71683686cdcc690f7983826db612e9f5910b55b18a011f1755f1c9b884f20681fdf
@@ -0,0 +1,57 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: build
9
+
10
+ on: [push, pull_request]
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-20.04
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby:
19
+ - 2.6
20
+ - 2.7
21
+ - '3.0'
22
+ - 3.1
23
+ gemfile:
24
+ - Gemfile.rails50
25
+ - Gemfile.rails51
26
+ - Gemfile.rails52 # Min ruby 2.2.2
27
+ - Gemfile.rails60 # Min ruby 2.5.0
28
+ - Gemfile.rails61 # Min ruby 2.5.0
29
+ exclude:
30
+ - gemfile: Gemfile.rails50
31
+ ruby: 2.7
32
+ - gemfile: Gemfile.rails50
33
+ ruby: '3.0'
34
+ - gemfile: Gemfile.rails50
35
+ ruby: 3.1
36
+ - gemfile: Gemfile.rails51
37
+ ruby: 2.7
38
+ - gemfile: Gemfile.rails51
39
+ ruby: '3.0'
40
+ - gemfile: Gemfile.rails51
41
+ ruby: 3.1
42
+ - gemfile: Gemfile.rails52
43
+ ruby: 2.7
44
+ - gemfile: Gemfile.rails52
45
+ ruby: '3.0'
46
+ - gemfile: Gemfile.rails52
47
+ ruby: 3.1
48
+
49
+ env:
50
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}
51
+ steps:
52
+ - uses: actions/checkout@v2
53
+ - uses: ruby/setup-ruby@v1
54
+ with:
55
+ ruby-version: ${{ matrix.ruby }}
56
+ bundler-cache: true
57
+ - run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  Changelog
2
2
  ===========
3
+
4
+ ## [v0.7.2](https://github.com/Apipie/apipie-rails/tree/v0.7.2) (2022-04-19)
5
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.7.1...v0.7.2)
6
+ * Added Korean locale. [#480](https://github.com/Apipie/apipie-rails/pull/480) (Jaehyun Shin ) [#757](https://github.com/Apipie/apipie-rails/pull/757) (Jorge Santos)
7
+ * `Security` Upgraded Bootstrap from 2.0.2 to 2.3.2, JQuery from 1.11.3 to 1.12.4 [#708](https://github.com/Apipie/apipie-rails/pull/708) (Nicolas Waissbluth)
8
+ * Fix ruby2 keyword argument warning [#756](https://github.com/Apipie/apipie-rails/pull/756) (Jorge Santos)
9
+
10
+ ## [v0.7.1](https://github.com/Apipie/apipie-rails/tree/v0.7.1) (2022-04-06)
11
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.7.0...v0.7.1)
12
+ * Skip extra parameters while validating the keys. [#690](https://github.com/Apipie/apipie-rails/pull/690) (Omkar Joshi)
13
+ * Support defining security mechanisms for Swagger [#711](https://github.com/Apipie/apipie-rails/pull/711) (Dan Leyden)
14
+ * Update boolean handling of false [#749](https://github.com/Apipie/apipie-rails/pull/749) (Colin Bruce)
15
+
16
+ Note: Up until and including v0.6.x, apipie-rails was silently ignoring allow_blank == false on String validation.
17
+ when allow_blank is not specified, it default to false. to allow blank strings, you must specify it as a parameter.
18
+
19
+ Alternatively, if you want to revert to the previous behavior, you can set this configuration option:
20
+ `Apipie.configuration.ignore_allow_blank_false = true`.
21
+
22
+ ## [v0.7.0](https://github.com/Apipie/apipie-rails/tree/v0.7.0) (2022-03-30)
23
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.6.0...v0.7.0)
24
+ * ArgumentError (invalid byte sequence in UTF-8) [#746](https://github.com/Apipie/apipie-rails/pull/746) (David Milanese)
25
+ * Fix allow_blank does not work [#733](https://github.com/Apipie/apipie-rails/pull/733) (CHEN Song)
26
+ * Fix schema generation for param descriptions using the array validator in option [#732](https://github.com/Apipie/apipie-rails/pull/732) (Frank Hock)
27
+ * Remove support for Rails 4 and Ruby <= 2.5 [#747](https://github.com/Apipie/apipie-rails/pull/747) (Mathieu Jobin)
28
+
29
+ ## [v0.6.0](https://github.com/Apipie/apipie-rails/tree/v0.6.0) (2022-03-29)
30
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.20...v0.6.0)
31
+ * Ruby 3.0 fixes [#716](https://github.com/Apipie/apipie-rails/pull/716) (hank-spokeo)
32
+ * only depends on actionpack and activesupport [#741](https://github.com/Apipie/apipie-rails/pull/741) (Mathieu Jobin)
33
+ * language fix, fallback to default locale [#726](https://github.com/Apipie/apipie-rails/pull/726) (Alex Coomans)
34
+
35
+ ## [v0.5.20](https://github.com/Apipie/apipie-rails/tree/v0.5.20) (2022-03-16)
36
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.19...v0.5.20)
37
+ * Update rel-eng (Oleh Fedorenko)
38
+ * Deprecate travis, run tests on github actions [#740](https://github.com/Apipie/apipie-rails/pull/740) (Mathieu Jobin)
39
+ * Update validator.rb [#739](https://github.com/Apipie/apipie-rails/pull/739) (Dmytro Budnyk)
40
+ * Fix wrong number of arguments for recorder#process [#725](https://github.com/Apipie/apipie-rails/pull/725) (rob mathews)
41
+ * Change "an" to "a" [#723](https://github.com/Apipie/apipie-rails/pull/723) (Naokimi)
42
+
3
43
  ## [v0.5.19](https://github.com/Apipie/apipie-rails/tree/v0.5.19) (2021-07-25)
4
44
  [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.18...v0.5.19)
5
45
  * Add rel-eng notebook (Oleh Fedorenko)
data/README.rst CHANGED
@@ -387,20 +387,20 @@ Example:
387
387
  end
388
388
  end
389
389
 
390
- api :POST, "/users", "Create an user"
390
+ api :POST, "/users", "Create a user"
391
391
  param_group :user
392
392
  def create
393
393
  # ...
394
394
  end
395
395
 
396
- api :PUT, "/users/:id", "Update an user"
396
+ api :PUT, "/users/:id", "Update a user"
397
397
  param_group :user
398
398
  def update
399
399
  # ...
400
400
  end
401
401
 
402
402
  # v2/users_controller.rb
403
- api :POST, "/users", "Create an user"
403
+ api :POST, "/users", "Create a user"
404
404
  param_group :user, V1::UsersController
405
405
  def create
406
406
  # ...
@@ -434,7 +434,7 @@ Example
434
434
  end
435
435
  end
436
436
 
437
- api :POST, "/users", "Create an user"
437
+ api :POST, "/users", "Create a user"
438
438
  param_group :user
439
439
  def create
440
440
  # ...
@@ -446,7 +446,7 @@ Example
446
446
  # ...
447
447
  end
448
448
 
449
- api :PUT, "/users/:id", "Update an user"
449
+ api :PUT, "/users/:id", "Update a user"
450
450
  param_group :user
451
451
  def update
452
452
  # ...
@@ -966,6 +966,9 @@ validate_presence
966
966
  validate_key
967
967
  Check the received params to ensure they are defined in the API. (false by default)
968
968
 
969
+ action_on_non_validated_keys
970
+ Either `:raise` or `:skip`. If `validate_key` fails, raise error or delete the non-validated key from the params and log the key (`:raise` by default)
971
+
969
972
  process_params
970
973
  Process and extract the parameter defined from the params of the request
971
974
  to the api_params variable
@@ -1021,6 +1024,10 @@ authorize
1021
1024
  show_all_examples
1022
1025
  Set this to true to set show_in_doc=1 in all recorded examples
1023
1026
 
1027
+ ignore_allow_blank_false
1028
+ `allow_blank: false` was incorrectly ignored up until version 0.6.0, this bug was fixed in 0.7.0
1029
+ if you need the old behavior, set this to true
1030
+
1024
1031
  link_extension
1025
1032
  The extension to use for API pages ('.html' by default). Link extensions
1026
1033
  in static API docs cannot be changed from '.html'.
@@ -1654,6 +1661,18 @@ There are several configuration parameters that determine the structure of the g
1654
1661
  If ``true``: the ``additional-properties: false`` field will not be included in response object descriptions
1655
1662
 
1656
1663
 
1664
+ ``config:swagger_security_definitions``
1665
+ If the API requires authentication, you can specify details of the authentication mechanisms supported as a (Hash) value here.
1666
+ See [https://swagger.io/docs/specification/2-0/authentication/] for details of what values can be specified
1667
+ By default, no security is defined.
1668
+
1669
+ ``config.swagger_global_security``
1670
+ If the API requires authentication, you can specify which of the authentication mechanisms are supported by all API operations as an Array of hashes here.
1671
+ This should be used in conjunction with the mechanisms defined by ``swagger_security_definitions``.
1672
+ See [https://swagger.io/docs/specification/2-0/authentication/] for details of what values can be specified
1673
+ By default, no security is defined.
1674
+
1675
+
1657
1676
  Known limitations of the current implementation
1658
1677
  -------------------------------------------------
1659
1678
  * There is currently no way to document the structure and content-type of the data returned from a method
@@ -1663,6 +1682,7 @@ Known limitations of the current implementation
1663
1682
  * It is not possible to leverage all of the parameter type/format capabilities of swagger
1664
1683
  * Only OpenAPI 2.0 is supported
1665
1684
  * Responses are defined inline and not as a $ref
1685
+ * It is not possible to specify per-operation security requirements (only global)
1666
1686
 
1667
1687
  ====================================
1668
1688
  Dynamic Swagger generation
data/apipie-rails.gemspec CHANGED
@@ -10,13 +10,14 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://github.com/Apipie/apipie-rails"
11
11
  s.summary = %q{Rails REST API documentation tool}
12
12
  s.description = %q{Rails REST API documentation tool}
13
- s.required_ruby_version = '>= 2.0.0'
13
+ s.required_ruby_version = '>= 2.6.0'
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_dependency "rails", ">= 4.1"
19
+ s.add_dependency "actionpack", ">= 5.0"
20
+ s.add_dependency "activesupport", ">= 5.0"
20
21
  s.add_development_dependency "rspec-rails", "~> 3.0"
21
22
  s.add_development_dependency "sqlite3"
22
23
  s.add_development_dependency "minitest"
@@ -100,7 +100,7 @@ module Apipie
100
100
  [:resource, :method, :version].each do |par|
101
101
  if params[par]
102
102
  splitted = params[par].split('.')
103
- if splitted.length > 1 && Apipie.configuration.languages.include?(splitted.last)
103
+ if splitted.length > 1 && (Apipie.configuration.languages.include?(splitted.last) || Apipie.configuration.default_locale == splitted.last)
104
104
  lang = splitted.last
105
105
  params[par].sub!(".#{lang}", '')
106
106
  end
@@ -1,8 +1,8 @@
1
1
  /* =============================================================
2
- * bootstrap-collapse.js v2.0.2
3
- * http://twitter.github.com/bootstrap/javascript.html#collapse
2
+ * bootstrap-collapse.js v2.3.2
3
+ * http://getbootstrap.com/2.3.2/javascript.html#collapse
4
4
  * =============================================================
5
- * Copyright 2012 Twitter, Inc.
5
+ * Copyright 2013 Twitter, Inc.
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -17,16 +17,21 @@
17
17
  * limitations under the License.
18
18
  * ============================================================ */
19
19
 
20
- !function( $ ){
21
20
 
22
- "use strict"
21
+ !function ($) {
23
22
 
24
- var Collapse = function ( element, options ) {
25
- this.$element = $(element)
23
+ "use strict"; // jshint ;_;
24
+
25
+
26
+ /* COLLAPSE PUBLIC CLASS DEFINITION
27
+ * ================================ */
28
+
29
+ var Collapse = function (element, options) {
30
+ this.$element = $(element)
26
31
  this.options = $.extend({}, $.fn.collapse.defaults, options)
27
32
 
28
- if (this.options["parent"]) {
29
- this.$parent = $(this.options["parent"])
33
+ if (this.options.parent) {
34
+ this.$parent = $(this.options.parent)
30
35
  }
31
36
 
32
37
  this.options.toggle && this.toggle()
@@ -42,31 +47,39 @@
42
47
  }
43
48
 
44
49
  , show: function () {
45
- var dimension = this.dimension()
46
- , scroll = $.camelCase(['scroll', dimension].join('-'))
47
- , actives = this.$parent && this.$parent.find('.in')
50
+ var dimension
51
+ , scroll
52
+ , actives
48
53
  , hasData
49
54
 
55
+ if (this.transitioning || this.$element.hasClass('in')) return
56
+
57
+ dimension = this.dimension()
58
+ scroll = $.camelCase(['scroll', dimension].join('-'))
59
+ actives = this.$parent && this.$parent.find('> .accordion-group > .in')
60
+
50
61
  if (actives && actives.length) {
51
62
  hasData = actives.data('collapse')
63
+ if (hasData && hasData.transitioning) return
52
64
  actives.collapse('hide')
53
65
  hasData || actives.data('collapse', null)
54
66
  }
55
67
 
56
68
  this.$element[dimension](0)
57
- this.transition('addClass', 'show', 'shown')
58
- this.$element[dimension](this.$element[0][scroll])
59
-
69
+ this.transition('addClass', $.Event('show'), 'shown')
70
+ $.support.transition && this.$element[dimension](this.$element[0][scroll])
60
71
  }
61
72
 
62
73
  , hide: function () {
63
- var dimension = this.dimension()
74
+ var dimension
75
+ if (this.transitioning || !this.$element.hasClass('in')) return
76
+ dimension = this.dimension()
64
77
  this.reset(this.$element[dimension]())
65
- this.transition('removeClass', 'hide', 'hidden')
78
+ this.transition('removeClass', $.Event('hide'), 'hidden')
66
79
  this.$element[dimension](0)
67
80
  }
68
81
 
69
- , reset: function ( size ) {
82
+ , reset: function (size) {
70
83
  var dimension = this.dimension()
71
84
 
72
85
  this.$element
@@ -74,41 +87,49 @@
74
87
  [dimension](size || 'auto')
75
88
  [0].offsetWidth
76
89
 
77
- this.$element[size ? 'addClass' : 'removeClass']('collapse')
90
+ this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
78
91
 
79
92
  return this
80
93
  }
81
94
 
82
- , transition: function ( method, startEvent, completeEvent ) {
95
+ , transition: function (method, startEvent, completeEvent) {
83
96
  var that = this
84
97
  , complete = function () {
85
- if (startEvent == 'show') that.reset()
98
+ if (startEvent.type == 'show') that.reset()
99
+ that.transitioning = 0
86
100
  that.$element.trigger(completeEvent)
87
101
  }
88
102
 
89
- this.$element
90
- .trigger(startEvent)
91
- [method]('in')
103
+ this.$element.trigger(startEvent)
104
+
105
+ if (startEvent.isDefaultPrevented()) return
106
+
107
+ this.transitioning = 1
108
+
109
+ this.$element[method]('in')
92
110
 
93
111
  $.support.transition && this.$element.hasClass('collapse') ?
94
112
  this.$element.one($.support.transition.end, complete) :
95
113
  complete()
96
- }
114
+ }
97
115
 
98
116
  , toggle: function () {
99
117
  this[this.$element.hasClass('in') ? 'hide' : 'show']()
100
- }
118
+ }
101
119
 
102
120
  }
103
121
 
104
- /* COLLAPSIBLE PLUGIN DEFINITION
105
- * ============================== */
106
122
 
107
- $.fn.collapse = function ( option ) {
123
+ /* COLLAPSE PLUGIN DEFINITION
124
+ * ========================== */
125
+
126
+ var old = $.fn.collapse
127
+
128
+ $.fn.collapse = function (option) {
108
129
  return this.each(function () {
109
130
  var $this = $(this)
110
131
  , data = $this.data('collapse')
111
- , options = typeof option == 'object' && option
132
+ , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option)
112
133
  if (!data) $this.data('collapse', (data = new Collapse(this, options)))
113
134
  if (typeof option == 'string') data[option]()
114
135
  })
@@ -121,18 +142,26 @@
121
142
  $.fn.collapse.Constructor = Collapse
122
143
 
123
144
 
124
- /* COLLAPSIBLE DATA-API
145
+ /* COLLAPSE NO CONFLICT
125
146
  * ==================== */
126
147
 
127
- $(function () {
128
- $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
129
- var $this = $(this), href
130
- , target = $this.attr('data-target')
131
- || e.preventDefault()
132
- || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
133
- , option = $(target).data('collapse') ? 'toggle' : $this.data()
134
- $(target).collapse(option)
135
- })
148
+ $.fn.collapse.noConflict = function () {
149
+ $.fn.collapse = old
150
+ return this
151
+ }
152
+
153
+
154
+ /* COLLAPSE DATA-API
155
+ * ================= */
156
+
157
+ $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
158
+ var $this = $(this), href
159
+ , target = $this.attr('data-target')
160
+ || e.preventDefault()
161
+ || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
162
+ , option = $(target).data('collapse') ? 'toggle' : $this.data()
163
+ $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
164
+ $(target).collapse(option)
136
165
  })
137
166
 
138
- }( window.jQuery );
167
+ }(window.jQuery);