swagger-dsl 1.5.1 → 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: 786aa5eea8ae2c2ce700f8c9bf9777da355f5647788d0fd7a1756316017bc182
4
- data.tar.gz: 879edc53b7549aa2d194428cdc66f94080adc7c1e306c9aa6d67612606d4639c
3
+ metadata.gz: 0e4b01a3c2f9182385dc31cf96d36b19781fb69c58403642c410e36e8e5cf3e0
4
+ data.tar.gz: ba787a1d0b03f8f214aca38482ad1e8dc7d9e7b9c8e7eea1c4d2e0432c9b4a4f
5
5
  SHA512:
6
- metadata.gz: f3462fb293dfb7f055d80ec3d027a2b33c9d5a973c84a0aaa2b84c566e7587bbfaa456a0e17e24321e1d525e22356314e9aa203d58f5c33ffac6d47d90d0f0e3
7
- data.tar.gz: eb112da3508f85283177a6bdfb375f487880b5f32a2c18f301d21f4f221981fe7cf3e42c84f868e933032254fa944d790618be327ceba1648d1b183be79d2df0
6
+ metadata.gz: 103ae693a31e19ea4c0c786f5b2add798da809a473f9113e7b297d39275a139f7089b1c300bfe2c40895a713c2e6011a6188cb4e722d44ae983cb2ded6082996
7
+ data.tar.gz: e8771d5f49a83fed9673a25e147d232920fc315affe95728a7293b7bdbf1d6a61ea6aa33c99c32dffa4c98dd1a43b46297008afc3b7b543fc254690cae58d9c9
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
@@ -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
@@ -16,7 +16,6 @@ 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"] = []
22
21
  self["tags"] = []
@@ -42,20 +41,24 @@ module Swagger
42
41
 
43
42
  def body(format: @format, dsl: nil, &block)
44
43
  formats(format).each do |f|
44
+ self["requestBody"] ||= { "required" => true }
45
+ self["requestBody"]["content"] ||= {}
45
46
  self["requestBody"]["content"][f] = { "schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block) }
46
47
  end
47
48
  end
48
49
 
49
50
  def body_description(body_description = nil)
51
+ self["requestBody"] ||= { "required" => true }
50
52
  self["requestBody"]["description"] = body_description
51
53
  end
52
54
 
53
55
  def body_optional(optional = true)
56
+ self["requestBody"] ||= {}
54
57
  self["requestBody"]["required"] = optional
55
58
  end
56
59
 
57
60
  def render(code = 200, format: @format, dsl: nil, &block)
58
- self["responses"][code] ||= { "content" => {} }
61
+ self["responses"][code] ||= { "content" => {}, "description" => "#{code}" }
59
62
  formats(format).each do |f|
60
63
  self["responses"][code]["content"][f] = { "schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block) }
61
64
  end
@@ -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.5.1".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,7 +28,7 @@ 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
34
  spec.add_dependency "activesupport", ">= 4.0.2"
@@ -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.5.1
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: 2021-03-19 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
@@ -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.5.1
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
@@ -281,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
309
  version: '0'
282
310
  requirements: []
283
311
  rubygems_version: 3.1.4
284
- signing_key:
312
+ signing_key:
285
313
  specification_version: 4
286
314
  summary: Swagger (OpenAPI 3) DSL
287
315
  test_files: []