swagger-dsl 1.4.0 → 2.0.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
  SHA256:
3
- metadata.gz: 4ec890325cd8a13a5777720b3351c4c041d91e393fba975379795bace2860d95
4
- data.tar.gz: 8082c1127a67be4060d2dbb32e1f89955b5b12642861198bdf1d0b627be750db
3
+ metadata.gz: 0e4b01a3c2f9182385dc31cf96d36b19781fb69c58403642c410e36e8e5cf3e0
4
+ data.tar.gz: ba787a1d0b03f8f214aca38482ad1e8dc7d9e7b9c8e7eea1c4d2e0432c9b4a4f
5
5
  SHA512:
6
- metadata.gz: ef51b9cdb97ec79798999e4b4d5414e8bdd9b79e696d5492e11a3ec2f16fbb63be0222fd81a03bbe9fd57532b1b4a7e87c074c2c6fc0e855814c8ba8075c0e87
7
- data.tar.gz: cce2fd4ff859619d69ab8fedf7668f7f70f83c60ab825ec31a60f40608f3fe30de2de82177815d68008c3d87530642860882f672b3488b9278da3483232f8f67
6
+ metadata.gz: 103ae693a31e19ea4c0c786f5b2add798da809a473f9113e7b297d39275a139f7089b1c300bfe2c40895a713c2e6011a6188cb4e722d44ae983cb2ded6082996
7
+ data.tar.gz: e8771d5f49a83fed9673a25e147d232920fc315affe95728a7293b7bdbf1d6a61ea6aa33c99c32dffa4c98dd1a43b46297008afc3b7b543fc254690cae58d9c9
File without changes
data/.gitignore CHANGED
File without changes
data/.prettierrc CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.rubocop.yml CHANGED
File without changes
data/.rubocop_airbnb.yml CHANGED
File without changes
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.0.0
4
+
5
+ - fix(brake): adjust to OAS3 spec
6
+
3
7
  ## 1.4.0
4
8
 
5
9
  - add: lazy_define_paths for Rails eager_load
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
File without changes
File without changes
File without changes
@@ -5,7 +5,7 @@ module Jimmy
5
5
  class SchemaCreation
6
6
  module Referencing
7
7
  def component(id)
8
- name = "#/components/#{id}"
8
+ name = "#/components/schemas/#{id}"
9
9
  reference_name = Swagger::DSL.current.config.dsl_options[:reference_name]
10
10
  reference_name ? reference_name.call(name) : name
11
11
  end
File without changes
File without changes
@@ -16,33 +16,49 @@ module Swagger
16
16
 
17
17
  def initialize(operation_id, format: :json, &block)
18
18
  self["operationId"] = operation_id
19
- self["requestBody"] = { "content" => {}, "required" => true }
20
19
  self["responses"] = {}
21
20
  self["parameters"] = []
21
+ self["tags"] = []
22
22
  @format = format
23
23
  instance_eval(&block)
24
24
  end
25
25
 
26
+ def summary(text)
27
+ self["summary"] = text
28
+ end
29
+
30
+ def description(text)
31
+ self["description"] = text
32
+ end
33
+
34
+ def tags(*tags)
35
+ self["tags"].concat(tags.flatten(1))
36
+ end
37
+
26
38
  def params(default_required: Swagger::DSL.current.config.default_required, &block)
27
39
  self["parameters"] = Parameters.new(default_required: default_required, &block)
28
40
  end
29
41
 
30
42
  def body(format: @format, dsl: nil, &block)
31
43
  formats(format).each do |f|
44
+ self["requestBody"] ||= { "required" => true }
45
+ self["requestBody"]["content"] ||= {}
32
46
  self["requestBody"]["content"][f] = { "schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block) }
33
47
  end
34
48
  end
35
49
 
36
50
  def body_description(body_description = nil)
51
+ self["requestBody"] ||= { "required" => true }
37
52
  self["requestBody"]["description"] = body_description
38
53
  end
39
54
 
40
55
  def body_optional(optional = true)
56
+ self["requestBody"] ||= {}
41
57
  self["requestBody"]["required"] = optional
42
58
  end
43
59
 
44
60
  def render(code = 200, format: @format, dsl: nil, &block)
45
- self["responses"][code] ||= { "content" => {} }
61
+ self["responses"][code] ||= { "content" => {}, "description" => "#{code}" }
46
62
  formats(format).each do |f|
47
63
  self["responses"][code]["content"][f] = { "schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block) }
48
64
  end
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -6,7 +6,7 @@ module Swagger
6
6
  module Serializer
7
7
  def swagger(dsl: nil, &block)
8
8
  name = self.name.sub(/Serializer$/, "")
9
- Swagger::DSL.current["components"][name] =
9
+ Swagger::DSL.current["components"]["schemas"][name] =
10
10
  Swagger::DSL::JsonSchema.by(dsl).dsl(&block).merge(Swagger::DSL.current.config.inject_key => name)
11
11
  end
12
12
 
@@ -1,5 +1,5 @@
1
1
  module Swagger
2
2
  class DSL < Hash
3
- VERSION = "1.4.0".freeze
3
+ VERSION = "2.0.0".freeze
4
4
  end
5
5
  end
data/lib/swagger/dsl.rb CHANGED
@@ -20,9 +20,10 @@ module Swagger
20
20
  def initialize(schema = nil, config: Config.new)
21
21
  merge!(schema || {})
22
22
  self["openapi"] ||= "3.0.0"
23
- self["info"] ||= {}
23
+ self["info"] ||= { "title" => "OpenAPI schema", "version" => "0.0.0" }
24
24
  self["paths"] ||= {}
25
- self["components"] = Components[self["components"] || {}]
25
+ self["components"] ||= {}
26
+ self["components"]["schemas"] = Components[self["components"]["schemas"] || {}]
26
27
  @config = config
27
28
  @define_paths_procs = []
28
29
  end
data/swagger-dsl.gemspec CHANGED
@@ -28,12 +28,12 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = %w[lib]
29
29
 
30
30
  spec.add_dependency "jimmy", "~> 0.5"
31
- spec.add_dependency "json-schema-subset-dsl", "~> 1.2"
31
+ spec.add_dependency "json-schema-subset-dsl", "~> 2.0"
32
32
  spec.add_dependency "hana", "~> 1.3"
33
33
  spec.add_dependency "json_refs", "~> 0.1"
34
- spec.add_dependency "activesupport", "~> 6.0"
34
+ spec.add_dependency "activesupport", ">= 4.0.2"
35
35
  spec.add_development_dependency "bundler", "~> 2.0"
36
- spec.add_development_dependency "rake", "~> 10.5"
36
+ spec.add_development_dependency "rake", "~> 13.0"
37
37
  spec.add_development_dependency "rspec", "~> 3.9"
38
38
  spec.add_development_dependency "rspec-power_assert", "~> 1.1"
39
39
  spec.add_development_dependency "rubocop", "~> 0.76"
@@ -42,4 +42,6 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency "rubocop-config-prettier", "~> 0.1"
43
43
  spec.add_development_dependency "yard", "~> 0.9"
44
44
  spec.add_development_dependency "pry-byebug", "~> 3.7"
45
+ spec.add_development_dependency "json_spec", "~> 1"
46
+ spec.add_development_dependency "openapi3_parser", "~> 0.9.1"
45
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger-dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Narazaka
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-07 00:00:00.000000000 Z
11
+ date: 2022-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jimmy
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.2'
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.2'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hana
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: activesupport
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '6.0'
75
+ version: 4.0.2
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '6.0'
82
+ version: 4.0.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '10.5'
103
+ version: '13.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '10.5'
110
+ version: '13.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -220,7 +220,35 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: '3.7'
223
- description:
223
+ - !ruby/object:Gem::Dependency
224
+ name: json_spec
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '1'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '1'
237
+ - !ruby/object:Gem::Dependency
238
+ name: openapi3_parser
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 0.9.1
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 0.9.1
251
+ description:
224
252
  email:
225
253
  - info@narazaka.net
226
254
  executables: []
@@ -264,8 +292,8 @@ metadata:
264
292
  homepage_uri: https://github.com/Narazaka/swagger-dsl
265
293
  source_code_uri: https://github.com/Narazaka/swagger-dsl.git
266
294
  changelog_uri: https://github.com/Narazaka/swagger-dsl/blob/master/CHANGELOG.md
267
- documentation_uri: https://www.rubydoc.info/gems/swagger-dsl/1.4.0
268
- post_install_message:
295
+ documentation_uri: https://www.rubydoc.info/gems/swagger-dsl/2.0.0
296
+ post_install_message:
269
297
  rdoc_options: []
270
298
  require_paths:
271
299
  - lib
@@ -280,9 +308,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
308
  - !ruby/object:Gem::Version
281
309
  version: '0'
282
310
  requirements: []
283
- rubyforge_project:
284
- rubygems_version: 2.7.6
285
- signing_key:
311
+ rubygems_version: 3.1.4
312
+ signing_key:
286
313
  specification_version: 4
287
314
  summary: Swagger (OpenAPI 3) DSL
288
315
  test_files: []