zero-rails_openapi 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -7
- data/lib/oas_objs/media_type_obj.rb +8 -7
- data/lib/open_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b19a052b847ba122b75b0b0fb1ecfa401c087a111fa18a7129b0553496298eb
|
4
|
+
data.tar.gz: 9baa8e072b95a4da0dae09c6538e6172d509231361806ee1613a066ec4d0fd81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4166f08378b66d7a80d7c26d2b893688e5c19f74cc8352eaf6e2a8f1217bbd2f9910285dc2d941193e0ea4fc10d8cf3270012c0491fb1583ae1282e28058e955
|
7
|
+
data.tar.gz: 315db1cf5d4cb569071f01fab825076157eb42d8b7261a6d131ddf22aae75c63fa7f5b6cc5b4d9309332a0bf57ab92c4d3e364749522be082b8e45902a9fbf73
|
data/README.md
CHANGED
@@ -132,12 +132,12 @@
|
|
132
132
|
### First of all, `include OpenApi::DSL` in your base class (which is for writing spec):
|
133
133
|
|
134
134
|
For example:
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
135
|
+
```ruby
|
136
|
+
# in app/controllers/api/api_controller.rb
|
137
|
+
class ApiController < ActionController::API
|
138
|
+
include OpenApi::DSL
|
139
|
+
end
|
140
|
+
```
|
141
141
|
|
142
142
|
### DSL Usage Example
|
143
143
|
|
@@ -452,10 +452,11 @@
|
|
452
452
|
|
453
453
|
```ruby
|
454
454
|
# ** Method Signature
|
455
|
-
response code, desc, media_type = nil, data: { }, **options
|
455
|
+
response code, desc, media_type = nil, headers: { }, data: { }, **options
|
456
456
|
# ** Usage
|
457
457
|
resp 200, 'success', :json, data: { name: 'test' }
|
458
458
|
response 200, 'query result', :pdf, data: File
|
459
|
+
response :success, 'succ', :json, headers: { 'X-Request-Start': String }, data: { }
|
459
460
|
|
460
461
|
# ** Method Signature
|
461
462
|
response_ref code_and_compkey_hash
|
@@ -7,21 +7,22 @@ module OpenApi
|
|
7
7
|
module DSL
|
8
8
|
# https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#media-type-object
|
9
9
|
class MediaTypeObj < Hash
|
10
|
-
attr_accessor :media_type, :schema, :examples
|
10
|
+
attr_accessor :media_type, :schema, :examples, :example
|
11
11
|
|
12
|
-
def initialize(media_type,
|
13
|
-
|
14
|
-
exp_params = schema_type.keys if
|
15
|
-
self.examples = ExampleObj.new(
|
12
|
+
def initialize(media_type, example: nil, examples: nil, exp_params: nil, **media_hash)
|
13
|
+
schema_type = media_hash.values_at(:type, :data).compact.first
|
14
|
+
exp_params = schema_type.keys if exp_params == :all
|
15
|
+
self.examples = ExampleObj.new(examples, exp_params, multiple: true) if examples.present?
|
16
|
+
self.example = ExampleObj.new(example) if example.present?
|
16
17
|
self.media_type = media_type_mapping(media_type)
|
17
|
-
self.schema = SchemaObj.new(
|
18
|
-
hash.except(:type, :data))
|
18
|
+
self.schema = SchemaObj.new(schema_type, media_hash.except(:type, :data))
|
19
19
|
end
|
20
20
|
|
21
21
|
def process
|
22
22
|
return { } if media_type.nil?
|
23
23
|
schema_processed = schema.process
|
24
24
|
result = schema_processed.values.join.blank? ? { } : { schema: schema_processed }
|
25
|
+
result[:example] = example.process unless example.nil?
|
25
26
|
result[:examples] = examples.process unless examples.nil?
|
26
27
|
{ media_type => result }
|
27
28
|
end
|
data/lib/open_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zero-rails_openapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhandao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|