api_schema 0.1.7 → 0.1.8

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
  SHA1:
3
- metadata.gz: 35b851123a21e5f4688f88f145ddf1e2881323a1
4
- data.tar.gz: e54cb55d27b82897bb098dc915a7b1b70fb81fff
3
+ metadata.gz: 48edcf5fff2d1e5085ff092725e2aaac654c0b6c
4
+ data.tar.gz: 48f52c3f854a1006f434801ce87f022a88e77281
5
5
  SHA512:
6
- metadata.gz: 6938dfbd1307a7af2da7b0e9aa61b552c250ae07927c516b8e101544fdc83087f5b2285f19a891f6f63cee9b541aa40e4fb785591e3fa91d87ccc720a2949a3d
7
- data.tar.gz: f2fab1d59adaefbf68ab0099c39729037a0bd6c584c34e3916eb7ca38770fbe8abc5f902a0682855a00bcb9494b905fae9e1b5f1e4e40f1caf19ca25ae075542
6
+ metadata.gz: 1ceb85a653f6e77e7677977504978c154d3b2e28fe306224f89598abd514d219e08d170c2effb92075a351128c4683d1a9f6eeac31a1a923d7c0316146d849eb
7
+ data.tar.gz: eba8fbcbaaf3b2f8183b9f8ca72769896612fa9953ebf208e20151a75bbaf551fa7c00c937ce3d22056188ef26511360c09cf8a1b1c0ae72b8b5f903a4bb3e1a
@@ -7,12 +7,18 @@ module ApiSchema
7
7
  :consumes, :produces, :authorization,
8
8
  :error_model, :error_desc
9
9
 
10
+ attr_reader :descriptions_path
11
+
10
12
  def initialize
11
13
  @error_model = 'error_model'
12
14
  @consumes = 'application/json'
13
15
  @produces = 'application/json'
14
16
  end
15
17
 
18
+ def descriptions_path=(descriptions_path)
19
+ @descriptions_path = "#{Dir.pwd}/#{descriptions_path}"
20
+ end
21
+
16
22
  def build
17
23
  configuration = self
18
24
  swagger_root do
@@ -2,10 +2,11 @@ module ApiSchema
2
2
  class ResourceDefinition
3
3
  include ::Swagger::Blocks::ClassMethods
4
4
 
5
- def initialize(method, base_path, extra_path = nil)
5
+ def initialize(method, api_version, base_path, extra_path = nil)
6
6
  @base_path = base_path
7
7
  @extra_path = extra_path
8
8
  @method = method
9
+ @api_version = api_version
9
10
  @header_params = []
10
11
  @path_params = []
11
12
  @query_params = []
@@ -15,7 +16,7 @@ module ApiSchema
15
16
  PathParam = ::Struct.new(:name, :type, :required)
16
17
  QueryParam = ::Struct.new(:name, :type, :required)
17
18
 
18
- attr_reader :method, :summary, :description, :header_params, :body_param,
19
+ attr_reader :method, :api_version, :summary, :description, :header_params, :body_param,
19
20
  :path_params, :query_params, :resp,
20
21
  :errors, :base_path, :extra_path, :full_path
21
22
 
@@ -27,6 +28,10 @@ module ApiSchema
27
28
  @description = desc
28
29
  end
29
30
 
31
+ def desc_file(desc_file)
32
+ @description = IO.read("#{api_version.configuration.descriptions_path}/#{desc_file}.md")
33
+ end
34
+
30
35
  def header(name, type, required: true)
31
36
  @header_params << HeaderParam.new(name, type, required)
32
37
  end
@@ -4,35 +4,35 @@ module ApiSchema
4
4
  private
5
5
 
6
6
  def get(base_path = default_path, extra_path: nil, &block)
7
- resource = ResourceDefinition.new(:get, base_path, extra_path)
7
+ resource = ResourceDefinition.new(:get, api_version, base_path, extra_path)
8
8
  resource.instance_eval(&block)
9
9
  api_version.resources << resource
10
10
  resource.build_neighbors(version_resources)
11
11
  end
12
12
 
13
13
  def post(base_path = default_path, extra_path: nil, &block)
14
- resource = ResourceDefinition.new(:post, base_path, extra_path)
14
+ resource = ResourceDefinition.new(:post, api_version, base_path, extra_path)
15
15
  resource.instance_eval(&block)
16
16
  api_version.resources << resource
17
17
  resource.build_neighbors(version_resources)
18
18
  end
19
19
 
20
20
  def put(base_path = default_path, extra_path: nil, &block)
21
- resource = ResourceDefinition.new(:put, base_path, extra_path)
21
+ resource = ResourceDefinition.new(:put, api_version, base_path, extra_path)
22
22
  resource.instance_eval(&block)
23
23
  api_version.resources << resource
24
24
  resource.build_neighbors(version_resources)
25
25
  end
26
26
 
27
27
  def patch(base_path = default_path, extra_path: nil, &block)
28
- resource = ResourceDefinition.new(:patch, base_path, extra_path)
28
+ resource = ResourceDefinition.new(:patch, api_version, base_path, extra_path)
29
29
  resource.instance_eval(&block)
30
30
  api_version.resources << resource
31
31
  resource.build_neighbors(version_resources)
32
32
  end
33
33
 
34
34
  def delete(base_path = default_path, extra_path: nil, &block)
35
- resource = ResourceDefinition.new(:delete, base_path, extra_path)
35
+ resource = ResourceDefinition.new(:delete, api_version, base_path, extra_path)
36
36
  resource.instance_eval(&block)
37
37
  api_version.resources << resource
38
38
  resource.build_neighbors(version_resources)
@@ -1,3 +1,3 @@
1
1
  module ApiSchema
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Chopey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-24 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport