swagger-dsl 1.0.0 → 1.1.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: 5cc961ef3920695d4d5ceb821614d851813f17d1260f770159114eccab257fb7
4
- data.tar.gz: 0bc99296d8a9855b7be3d3e2a6df2600b0ec923cbde9ce07d21a55bcaccac43d
3
+ metadata.gz: df246a1f449c1cb5be1e6d1353bd3a5f04863471ebc6e742d1474bb8f320729d
4
+ data.tar.gz: e7b9841234c25d9c0c44171cadfcdc2768cae499c1969e74569d7b8f25fd5369
5
5
  SHA512:
6
- metadata.gz: 2100a4b87f0274ec94a99bff02f358dac6248e6069afa3539a3925cdad8fdce40f3cc8f32d56a22c3323172ad8cfbfa87500e4b0a6cd7969172d9ebd47bcae49
7
- data.tar.gz: a4f54a4143025e57de805e945c1166de0bdd8b137ec1c1482c6be566f9fce550c0eeea2917791b6a411bc2f4ab20de5743116ff3f4e86affa03552074ee72604
6
+ metadata.gz: 33920f490f0899e4ec4a2fd1b5d25a53ead73b1e20712b7cbaf3ed9998d2af84abb9c77fa89f669ae858a0b9487a0c8335bdd81556f6edabb7f9b113704a9b01
7
+ data.tar.gz: 71319ffb954af6404a9eac5618f89a81d3d00c5d7b7c45959891bfa3560aa7d0b8d505fcdf96937d19f9cf10c0eeeb186b1c6cd908a359e69d8ce8cf877c6f15
@@ -0,0 +1,10 @@
1
+ # CHANGELOG
2
+
3
+ ## 1.1.0
4
+
5
+ - add: multiple format accept in params
6
+ - add: form shortcut in params format
7
+
8
+ ## 1.0.0
9
+
10
+ - released
data/README.md CHANGED
@@ -20,6 +20,8 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ see also [swagger-serializer](https://github.com/Narazaka/swagger-serializer)
24
+
23
25
  ```ruby
24
26
  class BaseSerializer
25
27
  extend Swagger::DSL::Serializer
@@ -78,7 +80,7 @@ Swagger::DSL.current["info"] = {
78
80
  "version" => "0.1.0",
79
81
  }
80
82
 
81
- JSON.dump(Swagger::DSL.current.as_json(except: "config"))
83
+ JSON.dump(Swagger::DSL.current)
82
84
  ```
83
85
 
84
86
  ## Development
@@ -5,7 +5,12 @@ module Swagger
5
5
  class DSL
6
6
  class Operation < Hash
7
7
  FORMAT_TYPE = {
8
- json: "application/json", xml: "application/xml", plain: "text/plain", html: "text/html", csv: "text/csv"
8
+ json: "application/json",
9
+ xml: "application/xml",
10
+ plain: "text/plain",
11
+ html: "text/html",
12
+ csv: "text/csv",
13
+ form: "application/x-www-form-urlencoded",
9
14
  }.freeze
10
15
 
11
16
  def initialize(operation_id, format: :json, &block)
@@ -22,9 +27,11 @@ module Swagger
22
27
  end
23
28
 
24
29
  def body(format: @format, dsl: nil, &block)
25
- self["requestBody"]["content"][FORMAT_TYPE[format]] = {
26
- "schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block)
27
- }
30
+ formats(format).each do |f|
31
+ self["requestBody"]["content"][f] = {
32
+ "schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block)
33
+ }
34
+ end
28
35
  end
29
36
 
30
37
  def body_description(body_description = nil)
@@ -37,9 +44,17 @@ module Swagger
37
44
 
38
45
  def render(code = 200, format: @format, dsl: nil, &block)
39
46
  self["responses"][code] ||= { "content" => {} }
40
- self["responses"][code]["content"][FORMAT_TYPE[format]] = {
41
- "schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block)
42
- }
47
+ formats(format).each do |f|
48
+ self["responses"][code]["content"][f] = {
49
+ "schema" => Swagger::DSL::JsonSchema.by(dsl).dsl(&block)
50
+ }
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ def formats(format)
57
+ Array(format).map { |f| FORMAT_TYPE[f] }
43
58
  end
44
59
  end
45
60
  end
@@ -6,7 +6,7 @@ module Swagger
6
6
  class DSL
7
7
  module ResolveModule
8
8
  def resolved
9
- JsonRefs.call(self.deep_dup)
9
+ JsonRefs.call(deep_dup)
10
10
  end
11
11
 
12
12
  def resolver
@@ -1,5 +1,5 @@
1
1
  module Swagger
2
2
  class DSL < Hash
3
- VERSION = "1.0.0".freeze
3
+ VERSION = "1.1.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger-dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Narazaka
@@ -233,6 +233,7 @@ files:
233
233
  - ".rspec"
234
234
  - ".rubocop.yml"
235
235
  - ".rubocop_airbnb.yml"
236
+ - CHANGELOG.md
236
237
  - Gemfile
237
238
  - LICENSE
238
239
  - README.md
@@ -263,7 +264,7 @@ metadata:
263
264
  homepage_uri: https://github.com/Narazaka/swagger-dsl
264
265
  source_code_uri: https://github.com/Narazaka/swagger-dsl.git
265
266
  changelog_uri: https://github.com/Narazaka/swagger-dsl/blob/master/CHANGELOG.md
266
- documentation_uri: https://www.rubydoc.info/gems/swagger-dsl/1.0.0
267
+ documentation_uri: https://www.rubydoc.info/gems/swagger-dsl/1.1.0
267
268
  post_install_message:
268
269
  rdoc_options: []
269
270
  require_paths: