swagger-core 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aba9b5a68451390562512924f4c3d9c67ef8e88
4
- data.tar.gz: e2861be404cf83fd74102030b6fd80015459d908
3
+ metadata.gz: 7cf6361f1aaca29c27ed5db6b69f02c52fa84d8e
4
+ data.tar.gz: 0c44de715f74ca30ffd3a0b3733ef1505065e55a
5
5
  SHA512:
6
- metadata.gz: 0a1b56875724d0abf2c28153988927db270dbcd412ed7b0ef63ae5c9775f42cced19068b16f35c3b60febb6d277a303ca43aad3227dd22ab83ab6990630e61ee
7
- data.tar.gz: 704dc9cc3df5f300a1afb1f099afc73897d1bce5dbde8b77a8a1eae5ca0e0add0a02093882806a4355b2b17b3a58c3011501bcf7b6ee907f35d34bdaa81ec5a0
6
+ metadata.gz: 34aba24af7c45545bb12b5a989c6cc6f844049c1301cc5fd845a69df474e975cb8100ff21f0cd0ed68e86ae7ddc6aa0d875574b39a4391dbd26b3afc46e33b7b
7
+ data.tar.gz: fd004cbb732785e6502b1eb62011512dd49a98b664e73550afb37f289a45b2f8037ccdc3dceb746c07a295bfd5e5bcb425544d4025c62dbebf656632cfb9ef41
@@ -1,23 +1 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-08-05 12:05:37 -0400 using RuboCop version 0.24.1.
3
- # The point is for the user to remove these configuration records
4
- # one by one as the offenses are removed from the code base.
5
- # Note that changes in the inspected code, or installation of new
6
- # versions of RuboCop, may require this file to be generated again.
7
-
8
- # Not yet...
9
- Style/Documentation:
10
- # See https://github.com/bbatsov/rubocop/issues/947
11
- # Use inch instead
12
- Enabled: false
13
- Style/Encoding:
14
- EnforcedStyle: when_needed
15
-
16
- Metrics/LineLength:
17
- Max: 120
18
- Metrics/MethodLength:
19
- Max: 15
20
-
21
- AllCops:
22
- Exclude:
23
- - 'swagger_spec/**/*'
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,76 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-02-04 16:29:20 -0500 using RuboCop version 0.47.1.
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: 3
10
+ Lint/IneffectiveAccessModifier:
11
+ Exclude:
12
+ - 'lib/swagger/builder.rb'
13
+
14
+ # Offense count: 1
15
+ Lint/NestedMethodDefinition:
16
+ Exclude:
17
+ - 'lib/swagger/builder.rb'
18
+
19
+ # Offense count: 2
20
+ # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
21
+ Lint/UselessAccessModifier:
22
+ Exclude:
23
+ - 'lib/swagger/builder.rb'
24
+
25
+ # Offense count: 8
26
+ # Configuration parameters: CountComments, ExcludedMethods.
27
+ Metrics/BlockLength:
28
+ Max: 71
29
+
30
+ # Offense count: 73
31
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
32
+ # URISchemes: http, https
33
+ Metrics/LineLength:
34
+ Max: 116
35
+
36
+ # Offense count: 3
37
+ # Configuration parameters: CountComments.
38
+ Metrics/MethodLength:
39
+ Max: 13
40
+
41
+ # Offense count: 1
42
+ # Cop supports --auto-correct.
43
+ Security/YAMLLoad:
44
+ Exclude:
45
+ - 'swagger_spec/test/validate_spec.rb'
46
+
47
+ # Offense count: 2
48
+ Style/Documentation:
49
+ Exclude:
50
+ - 'spec/**/*'
51
+ - 'test/**/*'
52
+ - 'lib/swagger.rb'
53
+ - 'lib/swagger/boolean.rb'
54
+
55
+ # Offense count: 2
56
+ # Cop supports --auto-correct.
57
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
58
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
59
+ Style/HashSyntax:
60
+ Exclude:
61
+ - 'swagger_spec/test/validate_spec.rb'
62
+
63
+ # Offense count: 1
64
+ # Cop supports --auto-correct.
65
+ Style/NestedParenthesizedCalls:
66
+ Exclude:
67
+ - 'swagger_spec/test/validate_spec.rb'
68
+
69
+ # Offense count: 3
70
+ # Cop supports --auto-correct.
71
+ # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
72
+ # SupportedStyles: slashes, percent_r, mixed
73
+ Style/RegexpLiteral:
74
+ Exclude:
75
+ - 'lib/swagger/mime_type.rb'
76
+ - 'swagger-core.gemspec'
@@ -1,6 +1,21 @@
1
1
  language: ruby
2
+ before_install: gem install bundler
3
+ install: bundle install --jobs=3 --retry=3
2
4
  rvm:
3
- - 2.1.0
4
- - 2.0.0
5
- - 1.9.3
6
- - jruby
5
+ - 2.0
6
+ - 2.1
7
+ - 2.2
8
+ - 2.3
9
+ - 2.4.0
10
+ gemfile:
11
+ - gemfile/mime_types_1.gemfile
12
+ - gemfile/mime_types_2.gemfile
13
+ - gemfile/mime_types_3.gemfile
14
+ deploy:
15
+ provider: rubygems
16
+ api_key:
17
+ secure: BMsVwSCrMbeCVICWMe5dobyr5nMOcugTwlDOjZCuWprIH/nk1G9zlRDO+j86/FGsc9yDolv4QM8HmS4KwA+/kiWfRRJtXsD9VEUkSwaSji8rFKpBaZjm9cZ13LNX5/LOzWW/n3nXGfbkNlpmIbX9XQt3BG7fVL5EVj03k7EQe4w=
18
+ gem: swagger-core
19
+ on:
20
+ tags: true
21
+ repo: swagger-rb/swagger-rb
data/Gemfile CHANGED
@@ -3,3 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in swagger.gemspec
4
4
  gemspec
5
5
  gem 'pry'
6
+
7
+ # temporary workaround for a problematic rainbow 2.2.0 release
8
+ # see https://github.com/sickill/rainbow/issues/40 for details
9
+ gem 'rainbow', '>= 2.1.0', '< 2.2.0'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Swagger
2
2
 
3
- Swagger is a Ruby library for parsing, building, and traversing (Swagger)[http://swagger.io/] API definitions.
3
+ Swagger is a Ruby library for parsing, building, and traversing [Swagger](http://swagger.io/) API definitions.
4
4
 
5
5
  ## Installation
6
6
 
@@ -0,0 +1,6 @@
1
+ gem "mime-types", "~> 1.0"
2
+ gemspec
3
+
4
+ # temporary workaround for a problematic rainbow 2.2.0 release
5
+ # see https://github.com/sickill/rainbow/issues/40 for details
6
+ gem 'rainbow', '>= 2.1.0', '< 2.2.0'
@@ -0,0 +1,6 @@
1
+ gem "mime-types", "~> 2.0"
2
+ gemspec
3
+
4
+ # temporary workaround for a problematic rainbow 2.2.0 release
5
+ # see https://github.com/sickill/rainbow/issues/40 for details
6
+ gem 'rainbow', '>= 2.1.0', '< 2.2.0'
@@ -0,0 +1,6 @@
1
+ gem "mime-types", "~> 3.0"
2
+ gemspec
3
+
4
+ # temporary workaround for a problematic rainbow 2.2.0 release
5
+ # see https://github.com/sickill/rainbow/issues/40 for details
6
+ gem 'rainbow', '>= 2.1.0', '< 2.2.0'
@@ -1,8 +1,9 @@
1
- require 'swagger/version'
2
- require 'swagger/boolean'
3
1
  require 'addressable/uri'
4
2
  require 'addressable/template'
3
+ require 'forwardable'
5
4
  require 'hashie'
5
+ require 'swagger/version'
6
+ require 'swagger/boolean'
6
7
 
7
8
  # Provides loading and building capabilities for Swagger.
8
9
  # @see http://swagger.io Swagger
@@ -8,7 +8,7 @@ module Swagger
8
8
  when '2'
9
9
  Swagger::V2::API.new hash
10
10
  else
11
- fail ArgumentError, "Swagger version #{version} is not currently supported"
11
+ raise ArgumentError, "Swagger version #{version} is not currently supported"
12
12
  end
13
13
  end
14
14
 
@@ -16,17 +16,16 @@ module Swagger
16
16
 
17
17
  # @api private
18
18
  def attach_to_children
19
- each_value do |v| # rubocop:disable Style/Next
19
+ each_value do |v|
20
20
  v.attach_parent self if v.respond_to? :attach_parent
21
21
  if v.respond_to? :each_value
22
22
  v.each_value do |sv|
23
23
  sv.attach_parent self if sv.respond_to? :attach_parent
24
24
  end
25
25
  end
26
- if v.respond_to? :each
27
- v.each do |sv|
28
- sv.attach_parent self if sv.respond_to? :attach_parent
29
- end
26
+ next unless v.respond_to? :each
27
+ v.each do |sv|
28
+ sv.attach_parent self if sv.respond_to? :attach_parent
30
29
  end
31
30
  end
32
31
  end
@@ -7,7 +7,7 @@ module Swagger
7
7
  val = obj.to_s.downcase
8
8
  return true if val.match(TRUE_REGEXP)
9
9
  return false if val.match(FALSE_REGEXP)
10
- fail ArgumentError, "#{obj} cannot be coerced to a boolean"
10
+ raise ArgumentError, "#{obj} cannot be coerced to a boolean"
11
11
  end
12
12
  end
13
13
  end
@@ -8,7 +8,7 @@ module Swagger
8
8
  # @api private
9
9
  module ClassMethods
10
10
  def self.extend_object(dash)
11
- fail TypeError, 'Bash only works on Dash' unless dash <= Hashie::Dash
11
+ raise TypeError, 'Bash only works on Dash' unless dash <= Hashie::Dash
12
12
  dash.instance_variable_get('@required_properties').clear
13
13
  dash.coerce_value Hashie::Dash, Swagger::Bash, strict: false
14
14
  end
@@ -20,21 +20,23 @@ module Swagger
20
20
 
21
21
  # @api private
22
22
  def self.included(dash) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
23
- fail TypeError, 'Bash only works on Dash' unless dash <= Hashie::Dash
23
+ raise TypeError, 'Bash only works on Dash' unless dash <= Hashie::Dash
24
24
  dash.extend ClassMethods
25
25
  dash.instance_variable_get('@required_properties').clear
26
26
 
27
27
  # Very hacky... copy instance_variables for coercions
28
28
  base_dash = dash.superclass
29
- [:@properties, :@defaults].each do | property |
29
+ [:@properties, :@defaults].each do |property|
30
30
  dash.instance_variable_set(property, base_dash.instance_variable_get(property))
31
31
  end
32
32
 
33
- [:@key_coercions, :@value_coercions].each do | property |
33
+ [:@key_coercions, :@value_coercions].each do |property|
34
34
  coercions = base_dash.instance_variable_get(property)
35
- coercions.each_pair do | key, into |
36
- infect_class coercions, key, into
37
- end if coercions
35
+ if coercions
36
+ coercions.each_pair do |key, into|
37
+ infect_class coercions, key, into
38
+ end
39
+ end
38
40
  dash.instance_variable_set(property, coercions)
39
41
  end
40
42
 
@@ -57,11 +59,11 @@ module Swagger
57
59
 
58
60
  def self.infect_class(coercions, key, into)
59
61
  if into.is_a? Hash
60
- into.each_pair do | sub_key, sub_into |
62
+ into.each_pair do |sub_key, sub_into|
61
63
  coercions[key][sub_key] = infect sub_into
62
64
  end
63
65
  elsif into.is_a? Array
64
- coercions[key] = into.map do | sub_into |
66
+ coercions[key] = into.map do |sub_into|
65
67
  infect sub_into
66
68
  end
67
69
  else
@@ -72,12 +74,13 @@ module Swagger
72
74
  def self.infect(klass)
73
75
  return klass unless klass <= Hashie::Dash
74
76
 
75
- klass.const_set('Bash',
76
- Class.new(klass).tap do | bash_klass |
77
- # include is public in Ruby 2.1+, hack to support older
78
- bash_klass.send(:include, Bash)
79
- end
80
- ) unless klass.const_defined? 'Bash'
77
+ unless klass.const_defined? 'Bash'
78
+ klass.const_set('Bash',
79
+ Class.new(klass).tap do |bash_klass|
80
+ # include is public in Ruby 2.1+, hack to support older
81
+ bash_klass.send(:include, Bash)
82
+ end)
83
+ end
81
84
 
82
85
  klass.const_get('Bash')
83
86
  end
@@ -102,7 +105,7 @@ module Swagger
102
105
  when '2'
103
106
  Swagger::V2::API
104
107
  else
105
- fail ArgumentError, "Swagger version #{version} is not currently supported"
108
+ raise ArgumentError, "Swagger version #{version} is not currently supported"
106
109
  end
107
110
  end
108
111
  end
@@ -15,12 +15,12 @@ module Swagger
15
15
  json: 'application/json',
16
16
  xml: 'application/xml',
17
17
  binary: 'application/octet-stream'
18
- }
18
+ }.freeze
19
19
 
20
20
  def initialize(mime_type_name)
21
21
  @mime_type_name = mime_type_name.to_s
22
22
  @mime_type = MIME::Types[@mime_type_name].first || base_type(@mime_type_name)
23
- fail ArgumentError, "Unknown mime type or suffix: #{mime_type_name}" if @mime_type.nil?
23
+ raise ArgumentError, "Unknown mime type or suffix: #{mime_type_name}" if @mime_type.nil?
24
24
  super @mime_type_name
25
25
  end
26
26
 
@@ -30,7 +30,7 @@ module Swagger
30
30
  when 'application/json'
31
31
  return JSON
32
32
  else
33
- fail NotImplementedError, "Parser support for #{mime_type} is not implemented"
33
+ raise NotImplementedError, "Parser support for #{mime_type} is not implemented"
34
34
  end
35
35
  end
36
36
 
@@ -10,8 +10,6 @@ module Swagger
10
10
  YAMLParser
11
11
  when '.json', '.js', :json
12
12
  JSONParser
13
- else
14
- nil
15
13
  end
16
14
  end
17
15
 
@@ -21,7 +19,12 @@ module Swagger
21
19
  # @param content [String] The YAML content to parse
22
20
  # @return [Hash] the parsed content
23
21
  def self.parse(content)
24
- YAML.load(content)
22
+ if YAML.respond_to? :safe_load
23
+ YAML.safe_load(content)
24
+ else
25
+ # rubocop:disable Security/YAMLLoad
26
+ YAML.load(content)
27
+ end
25
28
  end
26
29
  end
27
30
 
@@ -23,7 +23,7 @@ module Swagger
23
23
 
24
24
  count = 0
25
25
  until schema.refs_resolved?
26
- fail 'Could not resolve non-remote $refs 5 cycles - circular references?' if count >= 5
26
+ raise 'Could not resolve non-remote $refs 5 cycles - circular references?' if count >= 5
27
27
  schema.resolve_refs
28
28
  count += 1
29
29
  end
@@ -39,7 +39,7 @@ module Swagger
39
39
 
40
40
  def resolve_refs
41
41
  items_and_props = [deep_select('items'), deep_select('properties')].flatten.compact
42
- items_and_props.each do | item |
42
+ items_and_props.each do |item|
43
43
  key = item.delete('$ref')
44
44
  next if remote_ref? key
45
45
  model = root.definitions[key]
@@ -35,13 +35,13 @@ module Swagger
35
35
  field :externalDocs, Object # TODO: ExternalDocs class
36
36
  # @endgroup
37
37
 
38
- alias_method :base_path, :basePath
38
+ alias base_path basePath
39
39
 
40
40
  # All operations under all paths
41
41
  # @return [Array<Operation>]
42
42
  def operations
43
43
  # Perhaps not the best way...
44
- paths.values.map do | path |
44
+ paths.values.map do |path|
45
45
  path.operations.values
46
46
  end.flatten
47
47
  end
@@ -59,7 +59,7 @@ module Swagger
59
59
  def fully_validate
60
60
  # NOTE: fully_validate is ideal, but very slow with the current schema/validator
61
61
  errors = JSON::Validator.fully_validate(swagger_schema, to_json)
62
- fail Swagger::InvalidDefinition, errors unless errors.empty?
62
+ raise Swagger::InvalidDefinition, errors unless errors.empty?
63
63
  true
64
64
  end
65
65
 
@@ -23,10 +23,6 @@ module Swagger
23
23
  parser = Swagger::MimeType.parser_for(media_type)
24
24
  parser.parse(@raw)
25
25
  end
26
-
27
- def inspect
28
- @raw.inspect
29
- end
30
26
  end
31
27
  end
32
28
  end
@@ -8,7 +8,7 @@ module Swagger
8
8
  # @!group Fixed Fields
9
9
  field :description, String
10
10
  field :required, Swagger::Boolean
11
- alias_method :required?, :required
11
+ alias required? required
12
12
  field :type, String
13
13
  field :format, String
14
14
  field :items, Hash # TODO: Items Object
@@ -14,7 +14,7 @@ module Swagger
14
14
  field :summary, String
15
15
  field :description, String
16
16
  field :operationId, String
17
- alias_method :operation_id, :operationId
17
+ alias operation_id operationId
18
18
  field :produces, Array[String] # TODO: Need a lookup that merges w/ API-level field
19
19
  field :consumes, Array[String] # TODO: Need a lookup that merges w/ API-level field
20
20
  field :tags, Array[String] # TODO: This is an array of tag names, need to handle resolution name -> Tag object
@@ -23,6 +23,7 @@ module Swagger
23
23
  field :schemes, Array[String] # TODO: Need a lookup that merges w/ API-level field
24
24
  field :security, Array[SecurityRequirement] # TODO: Need a lookup that merges w/ API-level field
25
25
  field :externalDocs, Object # TODO: ExternalDocumentation class
26
+ field :deprecated, Boolean
26
27
 
27
28
  def api_title
28
29
  root.info.title
@@ -53,7 +54,7 @@ module Swagger
53
54
  # defined at the API level.
54
55
  def each_parameter
55
56
  return if parameters.nil?
56
- parameters.each do | parameter |
57
+ parameters.each do |parameter|
57
58
  yield parameter
58
59
  end
59
60
  end
@@ -6,12 +6,13 @@ module Swagger
6
6
  # @see https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#parameterObject Parameter Object
7
7
  class Parameter < SwaggerObject
8
8
  # @!group Fixed Fields
9
- required_field :name, String
9
+ # required_field :name, String
10
+ field :name, String
10
11
  # required_field :in, String
11
12
  field :in, String
12
13
  field :description, String
13
14
  field :required, Swagger::Boolean
14
- alias_method :required?, :required
15
+ alias required? required
15
16
  # @!endgroup
16
17
 
17
18
  # @!group Body Fields
@@ -26,6 +27,19 @@ module Swagger
26
27
  field :default, Object
27
28
  # @!endgroup
28
29
 
30
+ def parse
31
+ # resolve $ref parameters
32
+ schema = clone
33
+ if schema.key?('$ref')
34
+ # TODO: Make this smarter than just split, assuming local ref
35
+ key = schema.delete('$ref').split('/').last
36
+ model = root.parameters[key]
37
+ schema.merge!(model)
38
+ end
39
+
40
+ schema.to_hash
41
+ end
42
+
29
43
  include DeterministicJSONSchema
30
44
  end
31
45
  end
@@ -9,19 +9,14 @@ module Swagger
9
9
  extend Forwardable
10
10
  def_delegator :parent, :host
11
11
 
12
- VERBS = [:get, :put, :post, :delete, :options, :head, :patch]
13
- VERBS.each do | verb |
12
+ VERBS = [:get, :put, :post, :delete, :options, :head, :patch].freeze
13
+ VERBS.each do |verb|
14
14
  field verb, Operation
15
15
  end
16
16
  field :parameters, Array[Parameter]
17
17
 
18
- def initialize(hash)
19
- hash[:parameters] ||= []
20
- super
21
- end
22
-
23
18
  def operations
24
- VERBS.each_with_object({}) do | v, h |
19
+ VERBS.each_with_object({}) do |v, h|
25
20
  operation = send v
26
21
  h[v] = operation if operation
27
22
  end
@@ -38,7 +33,7 @@ module Swagger
38
33
  # Iterates over each Path level parameter.
39
34
  def each_parameter
40
35
  return if parameters.nil?
41
- parameters.each do | parameter |
36
+ parameters.each do |parameter|
42
37
  yield parameter
43
38
  end
44
39
  end
@@ -6,6 +6,10 @@ module Swagger
6
6
  # @see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#securitySchemeObject
7
7
  # Security Scheme Object
8
8
  class SecurityScheme < SwaggerObject
9
+ OAUTH2_TYPE = 'oauth'.freeze
10
+ API_KEY_TYPE = 'apikey'.freeze
11
+ FLOW_TYPES_REQUIRING_AUTHORIZATION_URL = %w(implicit accesscode).freeze
12
+ FLOW_TYPES_REQUIRING_TOKEN_URL = %w(password application accesscode).freeze
9
13
  # FIXME: Swagger documentation about what's required doesn't seem accurate - OSAuth2 centric?
10
14
 
11
15
  # According to docs, all except description are required. Schema and samples don't match.
@@ -13,13 +17,38 @@ module Swagger
13
17
  # @!group Fixed Fields
14
18
  required_field :type, String
15
19
  field :description, String
16
- field :name, String
17
- field :in, String
18
- required_field :flow, String
19
- required_field :authorizationUrl, String
20
- field :tokenUrl, String
21
- required_field :scopes, Hash
20
+
21
+ # Fields required for type apiKey
22
+ field :name, String # , required: :api_key?
23
+ field :in, String # , required: :api_key?
24
+
25
+ # Fields required for type oauth2
26
+ field :flow, String # , required: :oauth2?
27
+ field :scopes, Hash # , required: :oauth2?
28
+
29
+ # Fields required for oauth 2 for certain flow types
30
+ field :authorizationUrl, String # , required: :requires_authorization_url?
31
+ field :tokenUrl, String # , required: :requires_token_url?
22
32
  # @!endgroup
33
+
34
+ private
35
+
36
+ def oauth2?
37
+ type.to_s.downcase == OAUTH2_TYPE
38
+ end
39
+
40
+ def api_key?
41
+ type.to_s.downcase == API_KEY_TYPE
42
+ end
43
+
44
+ def requires_authorization_url?
45
+ oauth2? &&
46
+ FLOW_TYPES_REQUIRING_AUTHORIZATION_URL.include?(flow.to_s.downcase)
47
+ end
48
+
49
+ def requires_token_url?
50
+ oauth2? && FLOW_TYPES_REQUIRING_TOKEN_URL.include?(flow.to_s.downcase)
51
+ end
23
52
  end
24
53
  end
25
54
  end
@@ -1,3 +1,3 @@
1
1
  module Swagger
2
- VERSION = '0.2.3'
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -30,8 +30,6 @@ module Swagger
30
30
  subject { swagger.paths['/pets'].get.summary }
31
31
  it { is_expected.to eq('Gets pets') }
32
32
  end
33
-
34
- # rubocop:disable Metrics/LineLength
35
33
  describe '#description' do
36
34
  subject { swagger.paths['/pets'].get.description }
37
35
  it do
@@ -32,7 +32,14 @@ describe Swagger do
32
32
 
33
33
  context 'already parsed' do
34
34
  let(:swagger_file) { 'swagger_spec/examples/v2.0/yaml/petstore.yaml' }
35
- let(:content) { YAML.load(File.read(swagger_file)) }
35
+ let(:content) do
36
+ if YAML.respond_to? :safe_load
37
+ YAML.safe_load(File.read(swagger_file))
38
+ else
39
+ # rubocop:disable Security/YAMLLoad
40
+ YAML.load(File.read(swagger_file))
41
+ end
42
+ end
36
43
  subject(:swagger) { Swagger.build(content) }
37
44
  include_examples 'swagger loading'
38
45
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ module Swagger
4
+ module V2
5
+ describe Path do
6
+ subject(:path) { Path.new({}) }
7
+ describe 'initial fields' do
8
+ describe '#parameters' do
9
+ subject { path.parameters }
10
+ it { is_expected.to eq(nil) }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'addressable', '~> 2.3'
24
24
  spec.add_dependency 'hashie', '~> 3.0', '< 3.4.0'
25
25
  spec.add_dependency 'json-schema', '~> 2.2'
26
- spec.add_dependency 'mime-types', '~> 2.0'
27
- spec.add_development_dependency 'bundler', '~> 1.5'
26
+ spec.add_dependency 'mime-types'
27
+ spec.add_development_dependency 'bundler'
28
28
  spec.add_development_dependency 'rake'
29
29
  spec.add_development_dependency 'rspec'
30
30
  spec.add_development_dependency 'rubocop'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Lincoln
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-03 00:00:00.000000000 Z
11
+ date: 2017-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -62,30 +62,30 @@ dependencies:
62
62
  name: mime-types
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: '2.0'
67
+ version: '0'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '2.0'
74
+ version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: bundler
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '1.5'
81
+ version: '0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: '1.5'
88
+ version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: rake
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -169,12 +169,16 @@ files:
169
169
  - ".gitmodules"
170
170
  - ".rspec"
171
171
  - ".rubocop.yml"
172
+ - ".rubocop_todo.yml"
172
173
  - ".travis.yml"
173
174
  - ".yardopts"
174
175
  - Gemfile
175
176
  - LICENSE.txt
176
177
  - README.md
177
178
  - Rakefile
179
+ - gemfiles/mime_types_1.gemfile
180
+ - gemfiles/mime_types_2.gemfile
181
+ - gemfiles/mime_types_3.gemfile
178
182
  - lib/swagger.rb
179
183
  - lib/swagger/api.rb
180
184
  - lib/swagger/attachable.rb
@@ -210,6 +214,7 @@ files:
210
214
  - spec/swagger/info_spec.rb
211
215
  - spec/swagger/operation_spec.rb
212
216
  - spec/swagger/swagger_spec.rb
217
+ - spec/swagger/v2/path_spec.rb
213
218
  - swagger-core.gemspec
214
219
  homepage: https://github.com/maxlinc/swagger-rb
215
220
  licenses:
@@ -231,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
236
  version: '0'
232
237
  requirements: []
233
238
  rubyforge_project:
234
- rubygems_version: 2.4.2
239
+ rubygems_version: 2.6.8
235
240
  signing_key:
236
241
  specification_version: 4
237
242
  summary: Swagger parser for Ruby
@@ -244,4 +249,4 @@ test_files:
244
249
  - spec/swagger/info_spec.rb
245
250
  - spec/swagger/operation_spec.rb
246
251
  - spec/swagger/swagger_spec.rb
247
- has_rdoc:
252
+ - spec/swagger/v2/path_spec.rb