grape-swagger 1.6.1 → 2.0.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 +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +1 -0
- data/grape-swagger.gemspec +5 -5
- data/lib/grape-swagger/doc_methods/extensions.rb +2 -1
- data/lib/grape-swagger/doc_methods/move_params.rb +1 -0
- data/lib/grape-swagger/endpoint.rb +1 -1
- data/lib/grape-swagger/version.rb +1 -1
- metadata +26 -129
- data/.coveralls.yml +0 -1
- data/.github/dependabot.yml +0 -20
- data/.github/workflows/ci.yml +0 -120
- data/.gitignore +0 -45
- data/.rspec +0 -3
- data/.rubocop.yml +0 -136
- data/.rubocop_todo.yml +0 -45
- data/Dangerfile +0 -3
- data/Gemfile +0 -43
- data/Rakefile +0 -20
- data/example/api/endpoints.rb +0 -131
- data/example/api/entities.rb +0 -18
- data/example/config.ru +0 -42
- data/example/example_requests.postman_collection +0 -146
- data/example/splines.png +0 -0
- data/example/swagger-example.png +0 -0
- data/spec/issues/267_nested_namespaces.rb +0 -55
- data/spec/issues/403_versions_spec.rb +0 -124
- data/spec/issues/427_entity_as_string_spec.rb +0 -39
- data/spec/issues/430_entity_definitions_spec.rb +0 -94
- data/spec/issues/532_allow_custom_format_spec.rb +0 -38
- data/spec/issues/533_specify_status_code_spec.rb +0 -78
- data/spec/issues/537_enum_values_spec.rb +0 -50
- data/spec/issues/539_array_post_body_spec.rb +0 -65
- data/spec/issues/542_array_of_type_in_post_body_spec.rb +0 -46
- data/spec/issues/553_align_array_put_post_params_spec.rb +0 -144
- data/spec/issues/572_array_post_body_spec.rb +0 -51
- data/spec/issues/579_align_put_post_parameters_spec.rb +0 -179
- data/spec/issues/582_file_response_spec.rb +0 -55
- data/spec/issues/587_range_parameter_delimited_by_dash_spec.rb +0 -26
- data/spec/issues/605_root_route_documentation_spec.rb +0 -23
- data/spec/issues/650_params_array_spec.rb +0 -59
- data/spec/issues/677_consumes_produces_add_swagger_documentation_options_spec.rb +0 -100
- data/spec/issues/680_keep_204_error_schemas_spec.rb +0 -55
- data/spec/issues/751_deeply_nested_objects_spec.rb +0 -190
- data/spec/issues/776_multiple_presents_spec.rb +0 -59
- data/spec/issues/784_extensions_on_params_spec.rb +0 -38
- data/spec/issues/809_utf8_routes_spec.rb +0 -55
- data/spec/issues/832_array_hash_float_decimal_spec.rb +0 -111
- data/spec/issues/847_route_param_options_spec.rb +0 -37
- data/spec/lib/data_type_spec.rb +0 -111
- data/spec/lib/endpoint/params_parser_spec.rb +0 -124
- data/spec/lib/endpoint_spec.rb +0 -153
- data/spec/lib/extensions_spec.rb +0 -185
- data/spec/lib/format_data_spec.rb +0 -115
- data/spec/lib/model_parsers_spec.rb +0 -104
- data/spec/lib/move_params_spec.rb +0 -444
- data/spec/lib/oapi_tasks_spec.rb +0 -163
- data/spec/lib/operation_id_spec.rb +0 -55
- data/spec/lib/optional_object_spec.rb +0 -47
- data/spec/lib/parse_params_spec.rb +0 -82
- data/spec/lib/path_string_spec.rb +0 -101
- data/spec/lib/produces_consumes_spec.rb +0 -116
- data/spec/lib/tag_name_description_spec.rb +0 -80
- data/spec/lib/version_spec.rb +0 -28
- data/spec/spec_helper.rb +0 -39
- data/spec/support/empty_model_parser.rb +0 -23
- data/spec/support/grape_version.rb +0 -13
- data/spec/support/mock_parser.rb +0 -23
- data/spec/support/model_parsers/entity_parser.rb +0 -334
- data/spec/support/model_parsers/mock_parser.rb +0 -346
- data/spec/support/model_parsers/representable_parser.rb +0 -406
- data/spec/support/namespace_tags.rb +0 -93
- data/spec/support/the_paths_definitions.rb +0 -109
- data/spec/swagger_v2/api_documentation_spec.rb +0 -26
- data/spec/swagger_v2/api_swagger_v2_additional_properties_spec.rb +0 -83
- data/spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb +0 -48
- data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +0 -36
- data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +0 -79
- data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +0 -145
- data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +0 -137
- data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +0 -56
- data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +0 -64
- data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +0 -58
- data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +0 -57
- data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +0 -103
- data/spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb +0 -48
- data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +0 -145
- data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +0 -355
- data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +0 -217
- data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +0 -239
- data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +0 -72
- data/spec/swagger_v2/api_swagger_v2_response_spec.rb +0 -143
- data/spec/swagger_v2/api_swagger_v2_response_with_examples_spec.rb +0 -135
- data/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb +0 -216
- data/spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb +0 -55
- data/spec/swagger_v2/api_swagger_v2_response_with_root_spec.rb +0 -153
- data/spec/swagger_v2/api_swagger_v2_spec.rb +0 -237
- data/spec/swagger_v2/api_swagger_v2_status_codes_spec.rb +0 -93
- data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +0 -89
- data/spec/swagger_v2/boolean_params_spec.rb +0 -35
- data/spec/swagger_v2/default_api_spec.rb +0 -175
- data/spec/swagger_v2/deprecated_field_spec.rb +0 -25
- data/spec/swagger_v2/description_not_initialized_spec.rb +0 -39
- data/spec/swagger_v2/endpoint_versioned_path_spec.rb +0 -130
- data/spec/swagger_v2/errors_spec.rb +0 -77
- data/spec/swagger_v2/float_api_spec.rb +0 -33
- data/spec/swagger_v2/form_params_spec.rb +0 -67
- data/spec/swagger_v2/grape-swagger_spec.rb +0 -17
- data/spec/swagger_v2/guarded_endpoint_spec.rb +0 -162
- data/spec/swagger_v2/hide_api_spec.rb +0 -147
- data/spec/swagger_v2/host_spec.rb +0 -43
- data/spec/swagger_v2/inheritance_and_discriminator_spec.rb +0 -57
- data/spec/swagger_v2/mount_override_api_spec.rb +0 -58
- data/spec/swagger_v2/mounted_target_class_spec.rb +0 -76
- data/spec/swagger_v2/namespace_tags_prefix_spec.rb +0 -122
- data/spec/swagger_v2/namespace_tags_spec.rb +0 -78
- data/spec/swagger_v2/namespaced_api_spec.rb +0 -121
- data/spec/swagger_v2/nicknamed_api_spec.rb +0 -25
- data/spec/swagger_v2/operation_id_api_spec.rb +0 -27
- data/spec/swagger_v2/param_multi_type_spec.rb +0 -77
- data/spec/swagger_v2/param_type_spec.rb +0 -87
- data/spec/swagger_v2/param_values_spec.rb +0 -162
- data/spec/swagger_v2/params_array_collection_format_spec.rb +0 -105
- data/spec/swagger_v2/params_array_spec.rb +0 -203
- data/spec/swagger_v2/params_example_spec.rb +0 -40
- data/spec/swagger_v2/params_hash_spec.rb +0 -71
- data/spec/swagger_v2/params_nested_spec.rb +0 -86
- data/spec/swagger_v2/parent_less_namespace_spec.rb +0 -32
- data/spec/swagger_v2/reference_entity_spec.rb +0 -129
- data/spec/swagger_v2/security_requirement_spec.rb +0 -46
- data/spec/swagger_v2/simple_mounted_api_spec.rb +0 -326
- data/spec/version_spec.rb +0 -10
data/.rubocop_todo.yml
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# This configuration was generated by
|
|
2
|
-
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2023-05-20 18:23:47 UTC using RuboCop version 1.51.0.
|
|
4
|
-
# The point is for the user to remove these configuration records
|
|
5
|
-
# one by one as the offenses are removed from the code base.
|
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
-
|
|
9
|
-
# Offense count: 1
|
|
10
|
-
# Configuration parameters: Severity, Include.
|
|
11
|
-
# Include: **/*.gemspec
|
|
12
|
-
Gemspec/RequiredRubyVersion:
|
|
13
|
-
Exclude:
|
|
14
|
-
- 'grape-swagger.gemspec'
|
|
15
|
-
|
|
16
|
-
# Offense count: 32
|
|
17
|
-
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
18
|
-
Metrics/AbcSize:
|
|
19
|
-
Max: 56
|
|
20
|
-
|
|
21
|
-
# Offense count: 30
|
|
22
|
-
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
23
|
-
Metrics/MethodLength:
|
|
24
|
-
Max: 28
|
|
25
|
-
|
|
26
|
-
# Offense count: 8
|
|
27
|
-
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
28
|
-
Metrics/PerceivedComplexity:
|
|
29
|
-
Max: 16
|
|
30
|
-
|
|
31
|
-
# Offense count: 3
|
|
32
|
-
Style/ClassVars:
|
|
33
|
-
Exclude:
|
|
34
|
-
- 'lib/grape-swagger/doc_methods.rb'
|
|
35
|
-
|
|
36
|
-
# Offense count: 1
|
|
37
|
-
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
38
|
-
Style/CollectionCompact:
|
|
39
|
-
Exclude:
|
|
40
|
-
- 'lib/grape-swagger/endpoint.rb'
|
|
41
|
-
|
|
42
|
-
# Offense count: 23
|
|
43
|
-
# Configuration parameters: AllowedConstants.
|
|
44
|
-
Style/Documentation:
|
|
45
|
-
Enabled: false
|
data/Dangerfile
DELETED
data/Gemfile
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
source 'http://rubygems.org'
|
|
4
|
-
|
|
5
|
-
gemspec
|
|
6
|
-
|
|
7
|
-
gem 'grape', case version = ENV.fetch('GRAPE_VERSION', '~> 1.7')
|
|
8
|
-
when 'HEAD'
|
|
9
|
-
{ git: 'https://github.com/ruby-grape/grape' }
|
|
10
|
-
else
|
|
11
|
-
version
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
gem ENV.fetch('MODEL_PARSER', nil) if ENV.key?('MODEL_PARSER')
|
|
15
|
-
|
|
16
|
-
group :development, :test do
|
|
17
|
-
gem 'bundler'
|
|
18
|
-
gem 'grape-entity'
|
|
19
|
-
gem 'pry', platforms: [:mri]
|
|
20
|
-
gem 'pry-byebug', platforms: [:mri]
|
|
21
|
-
|
|
22
|
-
gem 'rack'
|
|
23
|
-
gem 'rack-cors'
|
|
24
|
-
gem 'rack-test'
|
|
25
|
-
gem 'rake'
|
|
26
|
-
gem 'rdoc'
|
|
27
|
-
gem 'rspec', '~> 3.9'
|
|
28
|
-
gem 'rubocop', '~> 1.50', require: false
|
|
29
|
-
gem 'webrick'
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
group :test do
|
|
33
|
-
gem 'coveralls_reborn', require: false
|
|
34
|
-
|
|
35
|
-
gem 'ruby-grape-danger', '~> 0.2.0', require: false
|
|
36
|
-
gem 'simplecov', require: false
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
group :test, :development do
|
|
40
|
-
unless ENV['MODEL_PARSER'] == 'grape-swagger-entity'
|
|
41
|
-
gem 'grape-swagger-entity', git: 'https://github.com/ruby-grape/grape-swagger-entity'
|
|
42
|
-
end
|
|
43
|
-
end
|
data/Rakefile
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'rubygems'
|
|
4
|
-
require 'bundler'
|
|
5
|
-
|
|
6
|
-
Bundler.setup(:default, :development)
|
|
7
|
-
|
|
8
|
-
require 'rake'
|
|
9
|
-
|
|
10
|
-
Bundler::GemHelper.install_tasks
|
|
11
|
-
|
|
12
|
-
require 'rspec/core'
|
|
13
|
-
require 'rspec/core/rake_task'
|
|
14
|
-
|
|
15
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
16
|
-
|
|
17
|
-
require 'rubocop/rake_task'
|
|
18
|
-
RuboCop::RakeTask.new(:rubocop)
|
|
19
|
-
|
|
20
|
-
task default: %i[spec rubocop]
|
data/example/api/endpoints.rb
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
require 'grape-entity'
|
|
2
|
-
require './api/entities'
|
|
3
|
-
|
|
4
|
-
module Api
|
|
5
|
-
class Spline
|
|
6
|
-
attr_accessor :id, :x, :y, :reticulated
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
module Endpoints
|
|
10
|
-
class Root < Grape::API
|
|
11
|
-
desc 'API Root'
|
|
12
|
-
get do
|
|
13
|
-
{
|
|
14
|
-
splines_url: '/splines',
|
|
15
|
-
file_url: '/file'
|
|
16
|
-
}
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
class Splines < Grape::API
|
|
21
|
-
@@splines = []
|
|
22
|
-
|
|
23
|
-
namespace :splines do
|
|
24
|
-
#
|
|
25
|
-
desc 'Get all splines',
|
|
26
|
-
is_array: true,
|
|
27
|
-
http_codes: [
|
|
28
|
-
{ code: 200, message: 'get Splines', model: Api::Entities::Splines },
|
|
29
|
-
{ code: 422, message: 'SplinesOutError' }
|
|
30
|
-
]
|
|
31
|
-
get do
|
|
32
|
-
present :items, @@splines, with: Entities::Splines
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
#
|
|
36
|
-
desc 'Return a spline.',
|
|
37
|
-
http_codes: [
|
|
38
|
-
{ code: 200, message: 'get Splines' },
|
|
39
|
-
{ code: 422, message: 'SplinesOutError' }
|
|
40
|
-
]
|
|
41
|
-
params do
|
|
42
|
-
requires :id, type: Integer, desc: 'Spline id.'
|
|
43
|
-
end
|
|
44
|
-
get ':id' do
|
|
45
|
-
error!(code: 422, message: 'SplinesOutError') unless @@splines[params[:id] - 1]
|
|
46
|
-
|
|
47
|
-
present @@splines[params[:id] - 1], with: Entities::Splines
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
#
|
|
51
|
-
desc 'Create a spline.',
|
|
52
|
-
http_codes: [
|
|
53
|
-
{ code: 201, message: 'Spline created', model: Api::Entities::Splines }
|
|
54
|
-
]
|
|
55
|
-
params do
|
|
56
|
-
requires :spline, type: Hash do
|
|
57
|
-
requires :x, type: Numeric
|
|
58
|
-
requires :y, type: Numeric
|
|
59
|
-
end
|
|
60
|
-
optional :reticulated, type: Boolean, default: true, desc: 'True if the spline is reticulated.'
|
|
61
|
-
end
|
|
62
|
-
post do
|
|
63
|
-
spline = Spline.new
|
|
64
|
-
spline.id = @@splines.size + 1
|
|
65
|
-
spline.x = (params[:spline][:x] / params[:spline][:y] || 0.0)
|
|
66
|
-
spline.y = (params[:spline][:y] / params[:spline][:x] || 0.0)
|
|
67
|
-
spline.reticulated = params[:reticulated]
|
|
68
|
-
|
|
69
|
-
@@splines << spline
|
|
70
|
-
|
|
71
|
-
present spline, with: Entities::Splines
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
#
|
|
75
|
-
desc 'Update a spline.',
|
|
76
|
-
http_codes: [
|
|
77
|
-
{ code: 200, message: 'update Splines', model: Api::Entities::Splines },
|
|
78
|
-
{ code: 422, message: 'SplinesOutError' }
|
|
79
|
-
]
|
|
80
|
-
params do
|
|
81
|
-
requires :id, type: Integer, desc: 'Spline id.'
|
|
82
|
-
optional :spline, type: Hash do
|
|
83
|
-
optional :x, type: Numeric
|
|
84
|
-
optional :y, type: Numeric
|
|
85
|
-
end
|
|
86
|
-
optional :reticulated, type: Boolean, default: true, desc: 'True if the spline is reticulated.'
|
|
87
|
-
end
|
|
88
|
-
put ':id' do
|
|
89
|
-
error!(code: 422, message: 'SplinesOutError') unless @@splines[params[:id] - 1]
|
|
90
|
-
|
|
91
|
-
update_data = params[:spline]
|
|
92
|
-
spline = @@splines[params[:id] - 1]
|
|
93
|
-
|
|
94
|
-
spline.reticulated = !!update_data[:reticulated]
|
|
95
|
-
spline.x = update_data[:x] / update_data[:y] || 0.0
|
|
96
|
-
spline.y = update_data[:y] / update_data[:x] || 0.0
|
|
97
|
-
|
|
98
|
-
present spline, with: Entities::Splines
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
#
|
|
102
|
-
desc 'Delete a spline.'
|
|
103
|
-
params do
|
|
104
|
-
requires :id, type: Integer, desc: 'Spline id.'
|
|
105
|
-
end
|
|
106
|
-
delete ':id' do
|
|
107
|
-
error!(code: 422, message: 'SplinesOutError') unless @@splines[params[:id] - 1]
|
|
108
|
-
|
|
109
|
-
@@splines.delete_at(params[:id] - 1)
|
|
110
|
-
{ 'deleted' => params[:id] }
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
class FileAccessor < Grape::API
|
|
116
|
-
namespace :file do
|
|
117
|
-
desc 'Update image',
|
|
118
|
-
details: "# TEST api for testing uploading\n
|
|
119
|
-
# curl --form file=@splines.png http://localhost:9292/file/upload",
|
|
120
|
-
content_type: 'application/octet-stream'
|
|
121
|
-
post 'upload' do
|
|
122
|
-
filename = params[:file][:filename]
|
|
123
|
-
content_type 'binary', 'application/octet-stream'
|
|
124
|
-
# env['api.format'] = :binary # there's no formatter for :binary, data will be returned "as is"
|
|
125
|
-
header 'Content-Disposition', "attachment; filename*=UTF-8''#{URI.escape(filename)}"
|
|
126
|
-
params[:file][:tempfile].read
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
data/example/api/entities.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'grape-entity'
|
|
2
|
-
|
|
3
|
-
module Api
|
|
4
|
-
module Entities
|
|
5
|
-
class Splines < Grape::Entity
|
|
6
|
-
expose :id, documentation: { type: Integer, desc: 'identity of a resource' }
|
|
7
|
-
expose :x, documentation: { type: Float, desc: 'x-value' }
|
|
8
|
-
expose :y, documentation: { type: Float, desc: 'y-value' }
|
|
9
|
-
expose :path, documentation: { type: String, desc: 'the requested resource' }
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def path
|
|
14
|
-
"/#{object.class.name.demodulize.to_s.underscore}/#{object.id}"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
data/example/config.ru
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
Bundler.require ENV['RACK_ENV']
|
|
2
|
-
|
|
3
|
-
use Rack::Cors do
|
|
4
|
-
allow do
|
|
5
|
-
origins '*'
|
|
6
|
-
resource '*', headers: :any, methods: [:get, :post, :put, :delete, :options]
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
require 'grape'
|
|
11
|
-
|
|
12
|
-
require './api/endpoints'
|
|
13
|
-
require './api/entities'
|
|
14
|
-
|
|
15
|
-
class Base < Grape::API
|
|
16
|
-
require '../lib/grape-swagger'
|
|
17
|
-
format :json
|
|
18
|
-
|
|
19
|
-
mount Api::Endpoints::Root
|
|
20
|
-
mount Api::Endpoints::Splines
|
|
21
|
-
mount Api::Endpoints::FileAccessor
|
|
22
|
-
|
|
23
|
-
before do
|
|
24
|
-
header['Access-Control-Allow-Origin'] = '*'
|
|
25
|
-
header['Access-Control-Request-Method'] = '*'
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# global exception handler, used for error notifications
|
|
29
|
-
rescue_from :all do |e|
|
|
30
|
-
raise e
|
|
31
|
-
error_response(message: "Internal server error: #{e}", status: 500)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
add_swagger_documentation hide_documentation_path: true,
|
|
35
|
-
api_version: 'v1',
|
|
36
|
-
info: {
|
|
37
|
-
title: 'Horses and Hussars',
|
|
38
|
-
description: 'Demo app for dev of grape swagger 2.0'
|
|
39
|
-
}
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
run Base.new
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "1a2c4a65-9c99-3435-17db-307763b28fd1",
|
|
3
|
-
"name": "grape-rackup",
|
|
4
|
-
"description": "",
|
|
5
|
-
"order": [
|
|
6
|
-
"cf633582-c2ea-cb44-24d7-d64e73a65049",
|
|
7
|
-
"60bd637b-7b77-b280-d4f7-3d3d38cd86ef",
|
|
8
|
-
"4780e2ef-f05d-f464-9d18-538c5960be3c",
|
|
9
|
-
"f83c2241-c239-13ea-bffb-255436e95863",
|
|
10
|
-
"0648649b-9e54-1bc5-f835-2c690f67d47a"
|
|
11
|
-
],
|
|
12
|
-
"folders": [],
|
|
13
|
-
"timestamp": 1453407636651,
|
|
14
|
-
"owner": "",
|
|
15
|
-
"remoteLink": "",
|
|
16
|
-
"public": false,
|
|
17
|
-
"requests": [
|
|
18
|
-
{
|
|
19
|
-
"id": "0648649b-9e54-1bc5-f835-2c690f67d47a",
|
|
20
|
-
"headers": "Content-Type: application/json\n",
|
|
21
|
-
"url": "http://localhost:9292/splines/1",
|
|
22
|
-
"preRequestScript": "",
|
|
23
|
-
"pathVariables": {},
|
|
24
|
-
"method": "DELETE",
|
|
25
|
-
"data": [],
|
|
26
|
-
"dataMode": "params",
|
|
27
|
-
"version": 2,
|
|
28
|
-
"tests": "",
|
|
29
|
-
"currentHelper": "normal",
|
|
30
|
-
"helperAttributes": {},
|
|
31
|
-
"time": 1453408596777,
|
|
32
|
-
"name": "http://localhost:9292/splines",
|
|
33
|
-
"description": "",
|
|
34
|
-
"collectionId": "1a2c4a65-9c99-3435-17db-307763b28fd1",
|
|
35
|
-
"responses": []
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"id": "4780e2ef-f05d-f464-9d18-538c5960be3c",
|
|
39
|
-
"headers": "Content-Type: application/json\n",
|
|
40
|
-
"url": "http://localhost:9292/splines/1",
|
|
41
|
-
"pathVariables": {},
|
|
42
|
-
"preRequestScript": "",
|
|
43
|
-
"method": "GET",
|
|
44
|
-
"collectionId": "1a2c4a65-9c99-3435-17db-307763b28fd1",
|
|
45
|
-
"data": [
|
|
46
|
-
{
|
|
47
|
-
"key": "required_group[required_param_1]",
|
|
48
|
-
"value": "sadf",
|
|
49
|
-
"type": "text",
|
|
50
|
-
"enabled": true
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"key": "required_group[required_param_2]",
|
|
54
|
-
"value": "fgsd",
|
|
55
|
-
"type": "text",
|
|
56
|
-
"enabled": true
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
|
-
"dataMode": "params",
|
|
60
|
-
"name": "http://localhost:9292/splines",
|
|
61
|
-
"description": "",
|
|
62
|
-
"descriptionFormat": "html",
|
|
63
|
-
"time": 1453408415061,
|
|
64
|
-
"version": 2,
|
|
65
|
-
"responses": [],
|
|
66
|
-
"tests": "",
|
|
67
|
-
"currentHelper": "normal",
|
|
68
|
-
"helperAttributes": {}
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"id": "60bd637b-7b77-b280-d4f7-3d3d38cd86ef",
|
|
72
|
-
"headers": "Content-Type: application/json\n",
|
|
73
|
-
"url": "http://localhost:9292/splines",
|
|
74
|
-
"pathVariables": {},
|
|
75
|
-
"preRequestScript": "",
|
|
76
|
-
"method": "GET",
|
|
77
|
-
"collectionId": "1a2c4a65-9c99-3435-17db-307763b28fd1",
|
|
78
|
-
"data": [
|
|
79
|
-
{
|
|
80
|
-
"key": "required_group[required_param_1]",
|
|
81
|
-
"value": "sadf",
|
|
82
|
-
"type": "text",
|
|
83
|
-
"enabled": true
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
"key": "required_group[required_param_2]",
|
|
87
|
-
"value": "fgsd",
|
|
88
|
-
"type": "text",
|
|
89
|
-
"enabled": true
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
"dataMode": "params",
|
|
93
|
-
"name": "http://localhost:9292/splines",
|
|
94
|
-
"description": "",
|
|
95
|
-
"descriptionFormat": "html",
|
|
96
|
-
"time": 1453408387712,
|
|
97
|
-
"version": 2,
|
|
98
|
-
"responses": [],
|
|
99
|
-
"tests": "",
|
|
100
|
-
"currentHelper": "normal",
|
|
101
|
-
"helperAttributes": {}
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"id": "cf633582-c2ea-cb44-24d7-d64e73a65049",
|
|
105
|
-
"headers": "Content-Type: application/json\n",
|
|
106
|
-
"url": "http://localhost:9292/splines",
|
|
107
|
-
"pathVariables": {},
|
|
108
|
-
"preRequestScript": "",
|
|
109
|
-
"method": "POST",
|
|
110
|
-
"collectionId": "1a2c4a65-9c99-3435-17db-307763b28fd1",
|
|
111
|
-
"data": [],
|
|
112
|
-
"dataMode": "raw",
|
|
113
|
-
"name": "http://localhost:9292/splines",
|
|
114
|
-
"description": "",
|
|
115
|
-
"descriptionFormat": "html",
|
|
116
|
-
"time": 1453407769825,
|
|
117
|
-
"version": 2,
|
|
118
|
-
"responses": [],
|
|
119
|
-
"tests": "",
|
|
120
|
-
"currentHelper": "normal",
|
|
121
|
-
"helperAttributes": {},
|
|
122
|
-
"rawModeData": "{\n \"spline\":{\n \"x\":1.23,\n \"y\":3.14\n }\n}"
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
"id": "f83c2241-c239-13ea-bffb-255436e95863",
|
|
126
|
-
"headers": "Content-Type: application/json\n",
|
|
127
|
-
"url": "http://localhost:9292/splines/1",
|
|
128
|
-
"pathVariables": {},
|
|
129
|
-
"preRequestScript": "",
|
|
130
|
-
"method": "PUT",
|
|
131
|
-
"collectionId": "1a2c4a65-9c99-3435-17db-307763b28fd1",
|
|
132
|
-
"data": [],
|
|
133
|
-
"dataMode": "raw",
|
|
134
|
-
"name": "http://localhost:9292/splines",
|
|
135
|
-
"description": "",
|
|
136
|
-
"descriptionFormat": "html",
|
|
137
|
-
"time": 1453408494448,
|
|
138
|
-
"version": 2,
|
|
139
|
-
"responses": [],
|
|
140
|
-
"tests": "",
|
|
141
|
-
"currentHelper": "normal",
|
|
142
|
-
"helperAttributes": {},
|
|
143
|
-
"rawModeData": "{\n \"spline\":{\n \"x\":131.23,\n \"y\":93.14\n }\n}"
|
|
144
|
-
}
|
|
145
|
-
]
|
|
146
|
-
}
|
data/example/splines.png
DELETED
|
Binary file
|
data/example/swagger-example.png
DELETED
|
Binary file
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe 'nested namespaces' do
|
|
6
|
-
let(:app) do
|
|
7
|
-
Class.new(Grape::API) do
|
|
8
|
-
route_param :root do
|
|
9
|
-
resources :apps do
|
|
10
|
-
route_param :app_id do
|
|
11
|
-
resource :build do
|
|
12
|
-
desc 'Builds an application'
|
|
13
|
-
post do
|
|
14
|
-
{ name: 'Test' }
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
add_swagger_documentation version: 'v1'
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe 'combined_namespace_routes' do
|
|
26
|
-
it 'parses root namespace properly' do
|
|
27
|
-
expect(app.combined_namespace_routes.keys).to include('apps')
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe '#extract_parent_route' do
|
|
32
|
-
it 'extracts parent for non-namespaced path properly' do
|
|
33
|
-
expect(app.send(:extract_parent_route, '/apps/:app_id/build')).to eq('apps')
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'extracts parent for namespaced path properly' do
|
|
37
|
-
expect(app.send(:extract_parent_route, '/:root/apps/:app_id/build')).to eq('apps')
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe 'retrieves swagger-documentation on /swagger_doc' do
|
|
42
|
-
let(:route_name) { '{root}/apps/{app_id}/build' }
|
|
43
|
-
|
|
44
|
-
subject do
|
|
45
|
-
get '/swagger_doc.json'
|
|
46
|
-
JSON.parse(last_response.body)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context 'paths' do
|
|
50
|
-
specify do
|
|
51
|
-
expect(subject['paths'].keys).to include "/#{route_name}"
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe 'describing versions' do
|
|
6
|
-
describe 'nothings given' do
|
|
7
|
-
def app
|
|
8
|
-
Class.new(Grape::API) do
|
|
9
|
-
desc 'no versions given'
|
|
10
|
-
get '/nothings' do
|
|
11
|
-
{ message: 'hello world …' }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
add_swagger_documentation format: :json
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
subject do
|
|
19
|
-
get '/swagger_doc'
|
|
20
|
-
JSON.parse(last_response.body)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
specify do
|
|
24
|
-
expect(subject['info']['version']).to eql '0.0.1'
|
|
25
|
-
expect(subject['paths'].keys.first).to eql '/nothings'
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
describe 'API version given' do
|
|
30
|
-
def app
|
|
31
|
-
Class.new(Grape::API) do
|
|
32
|
-
version 'v2', using: :path
|
|
33
|
-
desc 'api versions given'
|
|
34
|
-
get '/api_version' do
|
|
35
|
-
{ message: 'hello world …' }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
add_swagger_documentation format: :json
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
subject do
|
|
43
|
-
get '/v2/swagger_doc'
|
|
44
|
-
JSON.parse(last_response.body)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
specify do
|
|
48
|
-
expect(subject['info']['version']).to eql '0.0.1'
|
|
49
|
-
expect(subject['paths'].keys.first).to eql '/v2/api_version'
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe 'DOC version given' do
|
|
54
|
-
def app
|
|
55
|
-
Class.new(Grape::API) do
|
|
56
|
-
desc 'doc versions given'
|
|
57
|
-
get '/doc_version' do
|
|
58
|
-
{ message: 'hello world …' }
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
add_swagger_documentation doc_version: '0.1'
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
subject do
|
|
66
|
-
get '/swagger_doc'
|
|
67
|
-
JSON.parse(last_response.body)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
specify do
|
|
71
|
-
expect(subject['info']['version']).to eql '0.1'
|
|
72
|
-
expect(subject['paths'].keys.first).to eql '/doc_version'
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe 'both versions given' do
|
|
77
|
-
def app
|
|
78
|
-
Class.new(Grape::API) do
|
|
79
|
-
version :v3, using: :path
|
|
80
|
-
desc 'both versions given'
|
|
81
|
-
get '/both_versions' do
|
|
82
|
-
{ message: 'hello world …' }
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
add_swagger_documentation doc_version: '0.2'
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
subject do
|
|
90
|
-
get '/v3/swagger_doc'
|
|
91
|
-
JSON.parse(last_response.body)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
specify do
|
|
95
|
-
expect(subject['info']['version']).to eql '0.2'
|
|
96
|
-
expect(subject['paths'].keys.first).to eql '/v3/both_versions'
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
describe 'try to override grape given version' do
|
|
101
|
-
def app
|
|
102
|
-
Class.new(Grape::API) do
|
|
103
|
-
version :v4, using: :path
|
|
104
|
-
desc 'overriding grape given version?'
|
|
105
|
-
get '/grape_version' do
|
|
106
|
-
{ message: 'hello world …' }
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
add_swagger_documentation doc_version: '0.0.3',
|
|
110
|
-
version: 'v5'
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
subject do
|
|
115
|
-
get '/v4/swagger_doc'
|
|
116
|
-
JSON.parse(last_response.body)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
specify do
|
|
120
|
-
expect(subject['info']['version']).to eql '0.0.3'
|
|
121
|
-
expect(subject['paths'].keys.first).to eql '/v4/grape_version'
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe '#427 nested entity given as string' do
|
|
6
|
-
let(:app) do
|
|
7
|
-
Class.new(Grape::API) do
|
|
8
|
-
namespace :issue_427 do
|
|
9
|
-
module Permission
|
|
10
|
-
class WithoutRole < Grape::Entity
|
|
11
|
-
expose :id
|
|
12
|
-
expose :description
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
class RoleEntity < Grape::Entity
|
|
17
|
-
expose :id
|
|
18
|
-
expose :description
|
|
19
|
-
expose :role
|
|
20
|
-
expose :permissions, using: 'Permission::WithoutRole'
|
|
21
|
-
end
|
|
22
|
-
desc 'Get a list of roles',
|
|
23
|
-
success: RoleEntity
|
|
24
|
-
get '/' do
|
|
25
|
-
present [], with: RoleEntity
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
add_swagger_documentation format: :json
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
subject do
|
|
34
|
-
get '/swagger_doc'
|
|
35
|
-
JSON.parse(last_response.body)['definitions']
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
specify { expect(subject.keys).to include 'RoleEntity', 'Permission_WithoutRole' }
|
|
39
|
-
end
|