openapi_first 0.12.3 → 0.12.4

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
  SHA256:
3
- metadata.gz: 8f5e77e342d4dba0c6ac4d535511148333efac5bc4b2cea62ee6d8b75219233e
4
- data.tar.gz: 9b3341115e77bd4abc4b14d89464093d78483e251cf69e2b2508461c98aa1ccf
3
+ metadata.gz: c55b490840191990eac078738a26002b09f794b0f555ae1144faa679fadd7697
4
+ data.tar.gz: 855132c7c8893b9c02670926c820273aa4b7a407a6e7d02dd99ad2f600dd714f
5
5
  SHA512:
6
- metadata.gz: 86f19dc76569748825731014124b689b7bddf5cce6a6fe38b5d95adb4643eeeeaa3ae6024a290aaf2aed92127147cc948a55faa062b5d97b99b7d2fe65df98cd
7
- data.tar.gz: 27cef03d9ef7e0b49af33154e44ca68d3e0e860dcd94cbf6d2cdc4661ff90a4be590b92365aabfcdffe330f2aa2e96c12f7277ee2fa572fe02a2cc2c263e34b5
6
+ metadata.gz: a1acd2cfa2197bcf9dd760cbf63e146d6ffcc5b9a4fef1b291a0d781c095a06976d02b40fae2b6393307b6f958f34b489514e7dcb22bb89df186c2c31c76f1fe
7
+ data.tar.gz: 8832ddbbc1101985806d0752f74ab2ca14cc7322def44cc0d3537dec3d04592dfce8b2c8d646d21b100e427176dc7a176c3472fca28fc85ed4ae881757a471d1
@@ -14,6 +14,8 @@ Layout/SpaceAroundMethodCallOperator:
14
14
  Enabled: true
15
15
  Lint/DeprecatedOpenSSLConstant:
16
16
  Enabled: true
17
+ Lint/DuplicateElsifCondition:
18
+ Enabled: true
17
19
  Lint/RaiseException:
18
20
  Enabled: true
19
21
  Lint/MixedRegexpCaptureTypes:
@@ -28,9 +30,25 @@ Lint/StructNewOverride:
28
30
  Enabled: true
29
31
  Style/HashEachMethods:
30
32
  Enabled: false
33
+ Style/AccessorGrouping:
34
+ Enabled: true
35
+ Style/ArrayCoercion:
36
+ Enabled: true
37
+ Style/BisectedAttrAccessor:
38
+ Enabled: true
39
+ Style/CaseLikeIf:
40
+ Enabled: true
41
+ Style/HashAsLastArrayItem:
42
+ Enabled: true
43
+ Style/HashLikeCase:
44
+ Enabled: true
31
45
  Style/HashTransformKeys:
32
46
  Enabled: true
33
47
  Style/HashTransformValues:
34
48
  Enabled: true
49
+ Style/RedundantAssignment:
50
+ Enabled: true
35
51
  Style/RedundantFetchBlock:
36
52
  Enabled: true
53
+ Style/RedundantFileExtensionInRequire:
54
+ Enabled: true
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.4
4
+ - content-type is found while ignoring additional content-type parameters (`application/json` is found when request/response content-type is `application/json; charset=UTF8`)
5
+ - Support wildcard mime-types when finding the content-type
6
+
3
7
  ## 0.12.3
4
8
  - Add `response_validation:`, `router_raise_error` options to standalone mode.
5
9
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapi_first (0.12.3)
4
+ openapi_first (0.12.4)
5
5
  deep_merge (>= 1.2.1)
6
6
  hanami-router (~> 2.0.alpha3)
7
7
  hanami-utils (~> 2.0.alpha1)
@@ -39,9 +39,9 @@ GEM
39
39
  transproc (~> 1.0)
40
40
  hansi (0.2.0)
41
41
  hash-deep-merge (0.1.1)
42
- i18n (1.8.3)
42
+ i18n (1.8.4)
43
43
  concurrent-ruby (~> 1.0)
44
- json_schemer (0.2.11)
44
+ json_schemer (0.2.12)
45
45
  ecma-re-validator (~> 0.2)
46
46
  hana (~> 1.3)
47
47
  regexp_parser (~> 1.5)
@@ -92,7 +92,7 @@ GEM
92
92
  diff-lcs (>= 1.2.0, < 2.0)
93
93
  rspec-support (~> 3.9.0)
94
94
  rspec-support (3.9.3)
95
- rubocop (0.87.1)
95
+ rubocop (0.88.0)
96
96
  parallel (~> 1.10)
97
97
  parser (>= 2.7.1.1)
98
98
  rainbow (>= 2.2.2, < 4.0)
@@ -101,7 +101,7 @@ GEM
101
101
  rubocop-ast (>= 0.1.0, < 1.0)
102
102
  ruby-progressbar (~> 1.7)
103
103
  unicode-display_width (>= 1.4.0, < 2.0)
104
- rubocop-ast (0.1.0)
104
+ rubocop-ast (0.2.0)
105
105
  parser (>= 2.7.0.1)
106
106
  ruby-progressbar (1.10.1)
107
107
  ruby2_keywords (0.0.2)
@@ -111,7 +111,7 @@ GEM
111
111
  thread_safe (~> 0.1)
112
112
  unicode-display_width (1.7.0)
113
113
  uri_template (0.7.0)
114
- zeitwerk (2.3.1)
114
+ zeitwerk (2.4.0)
115
115
 
116
116
  PLATFORMS
117
117
  ruby
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- openapi_first (0.12.3)
4
+ openapi_first (0.12.4)
5
5
  deep_merge (>= 1.2.1)
6
6
  hanami-router (~> 2.0.alpha3)
7
7
  hanami-utils (~> 2.0.alpha1)
@@ -55,7 +55,7 @@ GEM
55
55
  dry-logic (~> 1.0, >= 1.0.2)
56
56
  ecma-re-validator (0.2.1)
57
57
  regexp_parser (~> 1.2)
58
- grape (1.3.3)
58
+ grape (1.4.0)
59
59
  activesupport
60
60
  builder
61
61
  dry-types (>= 1.1)
@@ -72,10 +72,10 @@ GEM
72
72
  transproc (~> 1.0)
73
73
  hansi (0.2.0)
74
74
  hash-deep-merge (0.1.1)
75
- i18n (1.8.3)
75
+ i18n (1.8.4)
76
76
  concurrent-ruby (~> 1.0)
77
77
  json_schema (0.20.9)
78
- json_schemer (0.2.11)
78
+ json_schemer (0.2.12)
79
79
  ecma-re-validator (~> 0.2)
80
80
  hana (~> 1.3)
81
81
  regexp_parser (~> 1.5)
@@ -125,7 +125,7 @@ GEM
125
125
  tzinfo (1.2.7)
126
126
  thread_safe (~> 0.1)
127
127
  uri_template (0.7.0)
128
- zeitwerk (2.3.1)
128
+ zeitwerk (2.4.0)
129
129
 
130
130
  PLATFORMS
131
131
  ruby
@@ -41,7 +41,7 @@ module OpenapiFirst
41
41
 
42
42
  raise ResponseInvalid, "Response has no content-type for '#{name}'" unless content_type
43
43
 
44
- media_type = content[content_type]
44
+ media_type = find_content_for_content_type(content, content_type)
45
45
  unless media_type
46
46
  message = "Response content type not found '#{content_type}' for '#{name}'"
47
47
  raise ResponseContentTypeNotFoundError, message
@@ -49,6 +49,12 @@ module OpenapiFirst
49
49
  media_type['schema']
50
50
  end
51
51
 
52
+ def request_body_schema_for(request_content_type)
53
+ content = @operation.request_body.content
54
+ media_type = find_content_for_content_type(content, request_content_type)
55
+ media_type&.fetch('schema', nil)
56
+ end
57
+
52
58
  def response_for(status)
53
59
  @operation.response_by_code(status.to_s, use_default: true).raw
54
60
  rescue OasParser::ResponseCodeNotFound
@@ -62,6 +68,13 @@ module OpenapiFirst
62
68
 
63
69
  private
64
70
 
71
+ def find_content_for_content_type(content, request_content_type)
72
+ content.fetch(request_content_type) do |_|
73
+ type = request_content_type.split(';')[0]
74
+ content[type] || content["#{type.split('/')[0]}/*"] || content['*/*']
75
+ end
76
+ end
77
+
65
78
  def build_parameters_json_schema
66
79
  return unless @operation.parameters&.any?
67
80
 
@@ -98,7 +98,8 @@ module OpenapiFirst
98
98
  def request_body_schema(content_type, operation)
99
99
  return unless operation
100
100
 
101
- schema = operation.request_body.content[content_type]&.fetch('schema')
101
+ schema = operation.request_body_schema_for(content_type)
102
+
102
103
  JSONSchemer.schema(schema) if schema
103
104
  end
104
105
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiFirst
4
- VERSION = '0.12.3'
4
+ VERSION = '0.12.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_first
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Haller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-10 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge