zero-rails_openapi 2.1.0 → 2.1.1

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: e1945a762cf400f52a4fbc222c7cd10e6fed4937e3d4afcb9357e4e030edf349
4
- data.tar.gz: f6b25115dd788832d34e5f83e4b216c49381367b80e0ae1c33a65fa964726b0d
3
+ metadata.gz: 3b19a052b847ba122b75b0b0fb1ecfa401c087a111fa18a7129b0553496298eb
4
+ data.tar.gz: 9baa8e072b95a4da0dae09c6538e6172d509231361806ee1613a066ec4d0fd81
5
5
  SHA512:
6
- metadata.gz: 56e62cdd21432ee8394ca955ca63498a9e198da18c553f30fa35840fad8219afc599bccb25e71a1c6565e513be26c3a2422c4e08c51b1e51ab48edd31423d813
7
- data.tar.gz: ce16f8ad8b4f83cdf5c7cbc4106b0f81354790a8febdeea0bf19b598f594e77505921260e832b6bf40f807ce580c9bef8c494b95c54de6d6d788e52c5032ef93
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
- ```ruby
136
- # in app/controllers/api/api_controller.rb
137
- class ApiController < ActionController::API
138
- include OpenApi::DSL
139
- end
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, hash)
13
- examples_hash = hash.delete(:examples)
14
- exp_params = schema_type.keys if (exp_params = hash.delete(:exp_params)) == :all
15
- self.examples = ExampleObj.new(examples_hash, exp_params, multiple: true) if examples_hash.present?
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(hash.values_at(:type, :data).compact.first,
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenApi
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.1'
5
5
  end
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.0
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-02-16 00:00:00.000000000 Z
11
+ date: 2019-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler