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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +3 -1
- data/lib/swagger/dsl/operation.rb +22 -7
- data/lib/swagger/dsl/resolve_module.rb +1 -1
- data/lib/swagger/dsl/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df246a1f449c1cb5be1e6d1353bd3a5f04863471ebc6e742d1474bb8f320729d
|
4
|
+
data.tar.gz: e7b9841234c25d9c0c44171cadfcdc2768cae499c1969e74569d7b8f25fd5369
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33920f490f0899e4ec4a2fd1b5d25a53ead73b1e20712b7cbaf3ed9998d2af84abb9c77fa89f669ae858a0b9487a0c8335bdd81556f6edabb7f9b113704a9b01
|
7
|
+
data.tar.gz: 71319ffb954af6404a9eac5618f89a81d3d00c5d7b7c45959891bfa3560aa7d0b8d505fcdf96937d19f9cf10c0eeeb186b1c6cd908a359e69d8ce8cf877c6f15
|
data/CHANGELOG.md
ADDED
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
|
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",
|
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
|
-
|
26
|
-
"
|
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
|
-
|
41
|
-
"
|
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
|
data/lib/swagger/dsl/version.rb
CHANGED
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.
|
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.
|
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:
|