apipie-rails 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +4 -3
- data/.github/workflows/rubocop-challenger.yml +1 -3
- data/.github/workflows/rubocop.yml +1 -1
- data/CHANGELOG.md +13 -0
- data/Gemfile +2 -3
- data/README.md +2088 -0
- data/apipie-rails.gemspec +7 -1
- data/app/views/apipie/apipies/_method_detail.erb +2 -0
- data/app/views/apipie/apipies/_params.html.erb +1 -0
- data/app/views/apipie/apipies/_params_plain.html.erb +1 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/lib/apipie/application.rb +1 -1
- data/lib/apipie/dsl_definition.rb +3 -3
- data/lib/apipie/extractor/writer.rb +1 -1
- data/lib/apipie/generator/swagger/method_description/response_service.rb +14 -1
- data/lib/apipie/param_description.rb +1 -1
- data/lib/apipie/response_description.rb +34 -9
- data/lib/apipie/response_description_adapter.rb +1 -1
- data/lib/apipie/routes_formatter.rb +1 -1
- data/lib/apipie/version.rb +1 -1
- data/rel-eng/gem_release.ipynb +5 -5
- data/spec/controllers/users_controller_spec.rb +1 -1
- data/spec/dummy/app/controllers/api/v2/empty_middle_controller.rb +1 -1
- data/spec/dummy/app/controllers/pets_controller.rb +1 -1
- data/spec/dummy/app/controllers/twitter_example_controller.rb +3 -3
- data/spec/lib/apipie/apipies_controller_spec.rb +1 -1
- data/spec/lib/apipie/file_handler_spec.rb +1 -1
- data/spec/lib/apipie/generator/swagger/method_description/response_service_spec.rb +62 -0
- data/spec/lib/apipie/generator/swagger/param_description/builder_spec.rb +2 -2
- data/spec/lib/apipie/param_description_spec.rb +1 -1
- data/spec/lib/apipie/response_description/response_object_spec.rb +22 -0
- data/spec/lib/apipie/response_description_spec.rb +56 -0
- data/spec/lib/swagger/swagger_dsl_spec.rb +1 -1
- metadata +12 -6
- data/README.rst +0 -1968
data/apipie-rails.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.version = Apipie::VERSION
|
9
9
|
s.authors = ["Pavel Pokorny","Ivan Necas"]
|
10
10
|
s.email = ["pajkycz@gmail.com", "inecas@redhat.com"]
|
11
|
-
s.homepage = "
|
11
|
+
s.homepage = "https://github.com/Apipie/apipie-rails"
|
12
12
|
s.summary = %q{Rails REST API documentation tool}
|
13
13
|
s.description = %q{Rails REST API documentation tool}
|
14
14
|
s.required_ruby_version = '>= 2.6.0'
|
@@ -17,6 +17,12 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
+
s.metadata = {
|
21
|
+
"bug_tracker_uri" => "https://github.com/Apipie/apipie-rails/issues",
|
22
|
+
"changelog_uri" => "https://github.com/Apipie/apipie-rails/blob/master/CHANGELOG.md",
|
23
|
+
"source_code_uri" => "https://github.com/Apipie/apipie-rails"
|
24
|
+
}
|
25
|
+
|
20
26
|
s.add_dependency "actionpack", ">= 5.0"
|
21
27
|
s.add_dependency "activesupport", ">= 5.0"
|
22
28
|
|
@@ -9,6 +9,7 @@
|
|
9
9
|
<small>
|
10
10
|
<%= param[:required] ? t('apipie.required') : t('apipie.optional') %>
|
11
11
|
<%= param[:allow_nil] ? ', '+t('apipie.nil_allowed') : '' %>
|
12
|
+
<%= param[:allow_blank] ? ', '+t('apipie.blank_allowed') : '' %>
|
12
13
|
<% if param[:validator] %>
|
13
14
|
[ <%= Apipie.markup_to_html(param[:validator]).html_safe %> ]
|
14
15
|
<% end %>
|
data/config/locales/en.yml
CHANGED
data/config/locales/ko.yml
CHANGED
data/lib/apipie/application.rb
CHANGED
@@ -89,7 +89,7 @@ module Apipie
|
|
89
89
|
|
90
90
|
# we create separate method description for each version in
|
91
91
|
# case the method belongs to more versions. We return just one
|
92
|
-
#
|
92
|
+
# because the version doesn't matter for the purpose it's used
|
93
93
|
# (to wrap the original version with validators)
|
94
94
|
ret_method_description ||= method_description
|
95
95
|
resource_description.add_method_description(method_description)
|
@@ -178,7 +178,7 @@ module Apipie
|
|
178
178
|
alias full_description desc
|
179
179
|
|
180
180
|
# describe next method with document in given path
|
181
|
-
# in
|
181
|
+
# in convention, these doc located under "#{Rails.root}/doc"
|
182
182
|
# Example:
|
183
183
|
# document "hello_world.md"
|
184
184
|
# def hello_world
|
@@ -452,7 +452,7 @@ module Apipie
|
|
452
452
|
include Apipie::DSL::Action
|
453
453
|
include Apipie::DSL::Param
|
454
454
|
|
455
|
-
# defines the substitutions to be made in the API paths
|
455
|
+
# defines the substitutions to be made in the API paths defined
|
456
456
|
# in concerns included. For example:
|
457
457
|
#
|
458
458
|
# There is this method defined in concern:
|
@@ -472,7 +472,7 @@ module Apipie
|
|
472
472
|
#
|
473
473
|
# It has to be specified before the concern is included.
|
474
474
|
#
|
475
|
-
# If not specified, the default predefined
|
475
|
+
# If not specified, the default predefined substitutions are
|
476
476
|
#
|
477
477
|
# {:conroller_path => controller.controller_path,
|
478
478
|
# :resource_id => `resource_id_from_apipie` }
|
@@ -419,7 +419,7 @@ module Apipie
|
|
419
419
|
end
|
420
420
|
|
421
421
|
# this method would be totally useless unless some clever guy
|
422
|
-
#
|
422
|
+
# decided that it would be great idea to change a behavior of
|
423
423
|
# "".lines method to not include end of lines.
|
424
424
|
#
|
425
425
|
# For more details:
|
@@ -39,7 +39,8 @@ class Apipie::Generator::Swagger::MethodDescription::ResponseService
|
|
39
39
|
allow_null: false,
|
40
40
|
http_method: @http_method,
|
41
41
|
controller_method: @method_description
|
42
|
-
).to_swagger
|
42
|
+
).to_swagger,
|
43
|
+
headers: response_headers(response.headers)
|
43
44
|
}.compact
|
44
45
|
end
|
45
46
|
end
|
@@ -55,4 +56,16 @@ class Apipie::Generator::Swagger::MethodDescription::ResponseService
|
|
55
56
|
|
56
57
|
{ 200 => { description: 'ok' } }
|
57
58
|
end
|
59
|
+
|
60
|
+
# @param [Array<Hash>] headers
|
61
|
+
#
|
62
|
+
# https://swagger.io/specification/v2/#header-object
|
63
|
+
def response_headers(headers)
|
64
|
+
headers.each_with_object({}) do |header, result|
|
65
|
+
result[header[:name].to_s] = {
|
66
|
+
description: header[:description],
|
67
|
+
type: header[:validator]
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
58
71
|
end
|
@@ -245,7 +245,7 @@ module Apipie
|
|
245
245
|
|
246
246
|
# makes modification that are based on the action that the param
|
247
247
|
# is defined for. Typical for required and allow_nil variations in
|
248
|
-
#
|
248
|
+
# create/update actions.
|
249
249
|
def action_awareness
|
250
250
|
if action_aware?
|
251
251
|
if !@options.key?(:allow_nil)
|
@@ -6,6 +6,7 @@ module Apipie
|
|
6
6
|
include Apipie::DSL::Param
|
7
7
|
|
8
8
|
attr_accessor :additional_properties, :typename
|
9
|
+
attr_reader :headers
|
9
10
|
|
10
11
|
def initialize(method_description, scope, block, typename)
|
11
12
|
@method_description = method_description
|
@@ -13,6 +14,7 @@ module Apipie
|
|
13
14
|
@param_group = {scope: scope}
|
14
15
|
@additional_properties = false
|
15
16
|
@typename = typename
|
17
|
+
@headers = []
|
16
18
|
|
17
19
|
self.instance_exec(&block) if block
|
18
20
|
|
@@ -43,6 +45,18 @@ module Apipie
|
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
48
|
+
# @param [String] header_name
|
49
|
+
# @param [String, symbol, Class] validator
|
50
|
+
# @param [String] description
|
51
|
+
# @param [Hash] options
|
52
|
+
def header(header_name, validator, description, options = {})
|
53
|
+
@headers << {
|
54
|
+
name: header_name,
|
55
|
+
validator: validator.to_s.downcase,
|
56
|
+
description: description,
|
57
|
+
options: options
|
58
|
+
}
|
59
|
+
end
|
46
60
|
end
|
47
61
|
end
|
48
62
|
|
@@ -64,15 +78,6 @@ module Apipie
|
|
64
78
|
adapter)
|
65
79
|
end
|
66
80
|
|
67
|
-
def is_array?
|
68
|
-
@is_array_of != false
|
69
|
-
end
|
70
|
-
|
71
|
-
def typename
|
72
|
-
@response_object.typename
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
81
|
def initialize(method_description, code, options, scope, block, adapter)
|
77
82
|
|
78
83
|
@type_ref = options[:param_group]
|
@@ -105,6 +110,14 @@ module Apipie
|
|
105
110
|
@response_object.additional_properties ||= options[:additional_properties]
|
106
111
|
end
|
107
112
|
|
113
|
+
def is_array?
|
114
|
+
@is_array_of != false
|
115
|
+
end
|
116
|
+
|
117
|
+
def typename
|
118
|
+
@response_object.typename
|
119
|
+
end
|
120
|
+
|
108
121
|
def param_description
|
109
122
|
nil
|
110
123
|
end
|
@@ -118,6 +131,17 @@ module Apipie
|
|
118
131
|
end
|
119
132
|
alias allow_additional_properties additional_properties
|
120
133
|
|
134
|
+
# @return [Array<Hash>]
|
135
|
+
def headers
|
136
|
+
# TODO: Support headers for Apipie::ResponseDescriptionAdapter
|
137
|
+
if @response_object.is_a?(Apipie::ResponseDescriptionAdapter)
|
138
|
+
return []
|
139
|
+
end
|
140
|
+
|
141
|
+
@response_object.headers
|
142
|
+
end
|
143
|
+
|
144
|
+
# @return [Hash{Symbol->TrueClass | FalseClass}]
|
121
145
|
def to_json(lang = nil)
|
122
146
|
{
|
123
147
|
:code => code,
|
@@ -125,6 +149,7 @@ module Apipie
|
|
125
149
|
:is_array => is_array?,
|
126
150
|
:returns_object => params_ordered.map{ |param| param.to_json(lang).tap{|h| h.delete(:validations) }}.flatten,
|
127
151
|
:additional_properties => additional_properties,
|
152
|
+
:headers => headers
|
128
153
|
}
|
129
154
|
end
|
130
155
|
end
|
@@ -24,7 +24,7 @@ module Apipie
|
|
24
24
|
if verb.count != 1
|
25
25
|
verb = API_METHODS.select{|defined_verb| defined_verb == rails_route.constraints[:method]}
|
26
26
|
if verb.blank?
|
27
|
-
raise "
|
27
|
+
raise "Unknown verb #{rails_route.path.spec.to_s}"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
verb.first
|
data/lib/apipie/version.rb
CHANGED
data/rel-eng/gem_release.ipynb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
"- push access to https://github.com/Apipie/apipie-rails\n",
|
11
11
|
"- push access to rubygems.org for apipie-rails\n",
|
12
12
|
"- sudo yum install python-slugify asciidoc\n",
|
13
|
-
"- ensure neither the `git push` or `gem push` don't require
|
13
|
+
"- ensure neither the `git push` or `gem push` don't require interactive auth. If you can't use api key or ssh key to auth skip these steps and run them form the shell manually\n",
|
14
14
|
"- ensure all checks have passed on the branch you're about to release\n",
|
15
15
|
"\n",
|
16
16
|
"### Release process\n",
|
@@ -117,7 +117,7 @@
|
|
117
117
|
"cell_type": "markdown",
|
118
118
|
"metadata": {},
|
119
119
|
"source": [
|
120
|
-
"### Run tests
|
120
|
+
"### Run tests locally if your setup allows, otherwise ensure the HEAD is green"
|
121
121
|
]
|
122
122
|
},
|
123
123
|
{
|
@@ -217,14 +217,14 @@
|
|
217
217
|
"cell_type": "markdown",
|
218
218
|
"metadata": {},
|
219
219
|
"source": [
|
220
|
-
"#### Manual step: Update deps in the gemspec if
|
220
|
+
"#### Manual step: Update deps in the gemspec if necessary"
|
221
221
|
]
|
222
222
|
},
|
223
223
|
{
|
224
224
|
"cell_type": "markdown",
|
225
225
|
"metadata": {},
|
226
226
|
"source": [
|
227
|
-
"### Check what is going to be
|
227
|
+
"### Check what is going to be committed"
|
228
228
|
]
|
229
229
|
},
|
230
230
|
{
|
@@ -347,7 +347,7 @@
|
|
347
347
|
"source": [
|
348
348
|
"### Some manual steps follow to improve the UX\n",
|
349
349
|
"\n",
|
350
|
-
"#### New
|
350
|
+
"#### New release on GitHub\n",
|
351
351
|
"\n",
|
352
352
|
"Copy the following changelog lines to the description in form on link below\n",
|
353
353
|
"The release title is the new version."
|
@@ -430,7 +430,7 @@ describe UsersController do
|
|
430
430
|
expect(b.full_description.length).to be > 400
|
431
431
|
end
|
432
432
|
|
433
|
-
context "
|
433
|
+
context "Using routes.rb" do
|
434
434
|
it "should contain basic info about method" do
|
435
435
|
a = Apipie[UsersController, :create_route]
|
436
436
|
expect(a.apis.count).to eq(1)
|
@@ -2,7 +2,7 @@ module Api
|
|
2
2
|
module V2
|
3
3
|
class EmptyMiddleController < V2::BaseController
|
4
4
|
# This is an empty controller, used to test cases where controllers
|
5
|
-
# may inherit from a middle
|
5
|
+
# may inherit from a middle controller that does not define a resource_description,
|
6
6
|
# but the middle controller's parent does.
|
7
7
|
|
8
8
|
def inconsequential_method
|
@@ -63,7 +63,7 @@ class PetsController < ApplicationController
|
|
63
63
|
# mixing request/response and response-only parameters
|
64
64
|
#
|
65
65
|
# the param_group :pet_with_id has several parameters which are
|
66
|
-
# not
|
66
|
+
# not expected in the request, but would show up in the response
|
67
67
|
# and vice versa
|
68
68
|
#-----------------------------------------------------------
|
69
69
|
def_param_group :pet_with_id do
|
@@ -10,7 +10,7 @@ class TwitterExampleController < ApplicationController
|
|
10
10
|
api :GET, '/twitter_example/lookup', 'Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two.'
|
11
11
|
param :screen_name, String, :desc => 'A comma separated list of screen names, up to 100 are allowed in a single request. You are strongly encouraged to use a POST for larger (up to 100 screen names) requests.'
|
12
12
|
param :user_id, Integer, :desc => 'A comma separated list of user IDs, up to 100 are allowed in a single request. You are strongly encouraged to use a POST for larger requests.'
|
13
|
-
param :include_entities, String, :desc => 'When set to either <code>true</code>, <code>t</code> or <code>1</code>, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a
|
13
|
+
param :include_entities, String, :desc => 'When set to either <code>true</code>, <code>t</code> or <code>1</code>, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discrete structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities.'
|
14
14
|
|
15
15
|
description <<-EOS
|
16
16
|
Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two. The author's most recent status (if the authenticating user has permission) will be returned inline.
|
@@ -53,8 +53,8 @@ class TwitterExampleController < ApplicationController
|
|
53
53
|
api :GET, '/twitter_example/search', 'Runs a search for users similar to Find People button on Twitter.com.'
|
54
54
|
param :q, String, :desc => 'The search query to run against people search.', :required => true
|
55
55
|
param :page, Integer, :desc => 'Specifies the page of results to retrieve.'
|
56
|
-
param :per_page, Integer, :desc => 'The number of people to retrieve.
|
57
|
-
param :include_entities, String, :desc => 'When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a
|
56
|
+
param :per_page, Integer, :desc => 'The number of people to retrieve. Maximum of 20 allowed per page.'
|
57
|
+
param :include_entities, String, :desc => 'When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discrete structure, including: user_mentions, urls, and hashtags. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities.'
|
58
58
|
description <<-EOS
|
59
59
|
Runs a search for users similar to Find People button on Twitter.com. The results returned by people search on Twitter.com are the same as those returned by this API request. Note that unlike GET search, this method does not support any operators.
|
60
60
|
|
@@ -188,7 +188,7 @@ describe Apipie::ApipiesController, type: :controller do
|
|
188
188
|
|
189
189
|
|
190
190
|
describe "authenticate user" do
|
191
|
-
it "authenticate user if an authentication method is
|
191
|
+
it "authenticate user if an authentication method is set" do
|
192
192
|
test = false
|
193
193
|
Apipie.configuration.authenticate = Proc.new do
|
194
194
|
test = true
|
@@ -15,7 +15,7 @@ describe Apipie::FileHandler do
|
|
15
15
|
it { expect { file_handler.match? path }.to_not raise_error }
|
16
16
|
end
|
17
17
|
|
18
|
-
context 'when the path
|
18
|
+
context 'when the path contains an invalid byte sequence in UTF-8' do
|
19
19
|
let(:path) { "%B6" }
|
20
20
|
|
21
21
|
it { expect(file_handler.match? path).to be_falsy }
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apipie::Generator::Swagger::MethodDescription::ResponseService do
|
4
|
+
let(:http_method) { nil }
|
5
|
+
let(:language) { :en }
|
6
|
+
let(:dsl_data) { ActionController::Base.send(:_apipie_dsl_data_init) }
|
7
|
+
|
8
|
+
let(:method_description) do
|
9
|
+
Apipie::Generator::Swagger::MethodDescription::Decorator.new(
|
10
|
+
Apipie::MethodDescription.new(
|
11
|
+
'create',
|
12
|
+
Apipie::ResourceDescription.new(ApplicationController, 'pets'),
|
13
|
+
dsl_data
|
14
|
+
)
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:returns) { [] }
|
19
|
+
|
20
|
+
let(:service) do
|
21
|
+
described_class.new(
|
22
|
+
method_description,
|
23
|
+
http_method: http_method,
|
24
|
+
language: language
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#call' do
|
29
|
+
describe 'headers' do
|
30
|
+
subject(:headers) { service.call[status_code][:headers] }
|
31
|
+
|
32
|
+
let(:status_code) { 200 }
|
33
|
+
|
34
|
+
it { is_expected.to be_blank }
|
35
|
+
|
36
|
+
context 'when headers exists' do
|
37
|
+
let(:dsl_data) { super().merge({ returns: returns }) }
|
38
|
+
let(:returns) { { status_code => [{}, nil, returns_dsl, nil] } }
|
39
|
+
|
40
|
+
let(:returns_dsl) do
|
41
|
+
proc do
|
42
|
+
header 'link', String, 'Relative links'
|
43
|
+
header 'Current-Page', Integer, 'The current page'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns the correct format headers' do
|
48
|
+
expect(headers).to eq({
|
49
|
+
'link' => {
|
50
|
+
description: 'Relative links',
|
51
|
+
type: 'string'
|
52
|
+
},
|
53
|
+
'Current-Page' => {
|
54
|
+
description: 'The current page',
|
55
|
+
type: 'integer'
|
56
|
+
}
|
57
|
+
})
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -118,7 +118,7 @@ describe Apipie::Generator::Swagger::ParamDescription::Builder do
|
|
118
118
|
{ required: false, default_value: nil }
|
119
119
|
end
|
120
120
|
|
121
|
-
it '
|
121
|
+
it 'does not warn' do
|
122
122
|
expect { subject }.not_to output(
|
123
123
|
/is optional but default value is not specified/
|
124
124
|
).to_stderr
|
@@ -130,7 +130,7 @@ describe Apipie::Generator::Swagger::ParamDescription::Builder do
|
|
130
130
|
{ required: false, default_value: 123 }
|
131
131
|
end
|
132
132
|
|
133
|
-
it '
|
133
|
+
it 'does not warn' do
|
134
134
|
expect { subject }.not_to output(
|
135
135
|
/is optional but default value is not specified/
|
136
136
|
).to_stderr
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apipie::ResponseDescription::ResponseObject do
|
4
|
+
describe '#header' do
|
5
|
+
let(:response_object) { described_class.new(nil, nil, nil, nil) }
|
6
|
+
let(:name) { 'Current-Page' }
|
7
|
+
let(:description) { 'The current page in the pagination' }
|
8
|
+
|
9
|
+
before { response_object.header(name, String, description) }
|
10
|
+
|
11
|
+
it 'adds it to the headers' do
|
12
|
+
expect(response_object.headers).to(
|
13
|
+
contain_exactly({
|
14
|
+
name: name,
|
15
|
+
description: description,
|
16
|
+
validator: 'string',
|
17
|
+
options: {}
|
18
|
+
})
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apipie::ResponseDescription do
|
4
|
+
let(:resource_description) do
|
5
|
+
Apipie::ResourceDescription.new(PetsController, 'pets')
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:method_description) do
|
9
|
+
Apipie::MethodDescription.new(
|
10
|
+
'create',
|
11
|
+
resource_description,
|
12
|
+
ActionController::Base.send(:_apipie_dsl_data_init)
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:response_description_dsl) { proc {} }
|
17
|
+
let(:options) { {} }
|
18
|
+
|
19
|
+
let(:response_description) do
|
20
|
+
described_class.new(
|
21
|
+
method_description,
|
22
|
+
204,
|
23
|
+
options,
|
24
|
+
PetsController,
|
25
|
+
response_description_dsl,
|
26
|
+
nil
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#to_json' do
|
31
|
+
let(:to_json) { response_description.to_json }
|
32
|
+
|
33
|
+
describe 'headers' do
|
34
|
+
subject(:headers) { to_json[:headers] }
|
35
|
+
|
36
|
+
it { is_expected.to be_blank }
|
37
|
+
|
38
|
+
context 'when response has headers' do
|
39
|
+
let(:response_description_dsl) do
|
40
|
+
proc do
|
41
|
+
header 'Current-Page', Integer, 'The current page in the pagination', required: true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns the header' do
|
46
|
+
expect(headers).to contain_exactly({
|
47
|
+
name: 'Current-Page',
|
48
|
+
description: 'The current page in the pagination',
|
49
|
+
validator: 'integer',
|
50
|
+
options: { required: true }
|
51
|
+
})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -283,7 +283,7 @@ describe "Swagger Responses" do
|
|
283
283
|
expect(schema).to have_field(:pet_id, 'number', {:description => 'id of pet'})
|
284
284
|
expect(schema).to have_field(:pet_name, 'string', {:description => 'Name of pet', :required => false})
|
285
285
|
expect(schema).to have_field(:animal_type, 'string', {:description => 'Type of pet', :enum => %w[dog cat iguana kangaroo]})
|
286
|
-
expect(schema).not_to have_field(:partial_match_allowed, 'boolean', {:required => false})
|
286
|
+
expect(schema).not_to have_field(:partial_match_allowed, 'boolean', {:required => false}) # rubocop:disable Capybara/NegationMatcher
|
287
287
|
end
|
288
288
|
|
289
289
|
it "creates a swagger definition with all input parameters" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apipie-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pokorny
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -215,7 +215,7 @@ files:
|
|
215
215
|
- MIT-LICENSE
|
216
216
|
- NOTICE
|
217
217
|
- PROPOSAL_FOR_RESPONSE_DESCRIPTIONS.md
|
218
|
-
- README.
|
218
|
+
- README.md
|
219
219
|
- Rakefile
|
220
220
|
- apipie-rails.gemspec
|
221
221
|
- app/controllers/apipie/apipies_controller.rb
|
@@ -419,6 +419,7 @@ files:
|
|
419
419
|
- spec/lib/apipie/generator/swagger/context_spec.rb
|
420
420
|
- spec/lib/apipie/generator/swagger/method_description/api_schema_service_spec.rb
|
421
421
|
- spec/lib/apipie/generator/swagger/method_description/response_schema_service_spec.rb
|
422
|
+
- spec/lib/apipie/generator/swagger/method_description/response_service_spec.rb
|
422
423
|
- spec/lib/apipie/generator/swagger/operation_id_spec.rb
|
423
424
|
- spec/lib/apipie/generator/swagger/param_description/builder_spec.rb
|
424
425
|
- spec/lib/apipie/generator/swagger/param_description/composite_spec.rb
|
@@ -442,6 +443,8 @@ files:
|
|
442
443
|
- spec/lib/apipie/param_description_spec.rb
|
443
444
|
- spec/lib/apipie/param_group_spec.rb
|
444
445
|
- spec/lib/apipie/resource_description_spec.rb
|
446
|
+
- spec/lib/apipie/response_description/response_object_spec.rb
|
447
|
+
- spec/lib/apipie/response_description_spec.rb
|
445
448
|
- spec/lib/apipie/response_does_not_match_swagger_schema_spec.rb
|
446
449
|
- spec/lib/apipie/swagger_generator_spec.rb
|
447
450
|
- spec/lib/apipie/validator_spec.rb
|
@@ -454,9 +457,12 @@ files:
|
|
454
457
|
- spec/support/custom_bool_validator.rb
|
455
458
|
- spec/support/rake.rb
|
456
459
|
- spec/test_engine/memes_controller_spec.rb
|
457
|
-
homepage:
|
460
|
+
homepage: https://github.com/Apipie/apipie-rails
|
458
461
|
licenses: []
|
459
|
-
metadata:
|
462
|
+
metadata:
|
463
|
+
bug_tracker_uri: https://github.com/Apipie/apipie-rails/issues
|
464
|
+
changelog_uri: https://github.com/Apipie/apipie-rails/blob/master/CHANGELOG.md
|
465
|
+
source_code_uri: https://github.com/Apipie/apipie-rails
|
460
466
|
post_install_message:
|
461
467
|
rdoc_options: []
|
462
468
|
require_paths:
|
@@ -472,7 +478,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
472
478
|
- !ruby/object:Gem::Version
|
473
479
|
version: '0'
|
474
480
|
requirements: []
|
475
|
-
rubygems_version: 3.
|
481
|
+
rubygems_version: 3.5.9
|
476
482
|
signing_key:
|
477
483
|
specification_version: 4
|
478
484
|
summary: Rails REST API documentation tool
|