swagger_api 0.2.8 → 0.2.9

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: 5e9c5b528e467eb55401a356909631108989fc40
4
- data.tar.gz: 92af23449557c3b49e38035c29cb73d15e606863
3
+ metadata.gz: 1cb3bbfda85e560abdea01543ed17e09a12dbbf4
4
+ data.tar.gz: 56c66db2c4a70c2ee4b134ab7da33d431d1ba973
5
5
  SHA512:
6
- metadata.gz: 32ec574e9661dbf0b676d8ec7478e4ae90411327f94f7fc4ae6930f2c5c61ebbeb5e9504806a43693d16c8eed4f730202ee07aff562cb1c8e7e16fbc89e3bdea
7
- data.tar.gz: f3e679d6c7cd6deb5455ef270a8fdd317527d0c08bdfe1a95da55a8314955f2492390ceb8f984ab481ad8c30198204b67f5b9dd61401940225f210041c0b4327
6
+ metadata.gz: 940cf5e6d78cd653bfa1c9e43aab10f54ed88c32c573b4a6d39dafb76a3b3d6022855dea3e2726faafff02cd8dd8dc1cdee6308c8dfda1c77557b66e3a3e7403
7
+ data.tar.gz: ac3a1b68c7ea692fc6926dc8d1e34523980554850583a2b73cc26f7c2971165b6eeb4bc4a759cb6a018c24720bdfa99b98ff48c47838a79a70625aad9904e406
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swagger_api (0.2.6)
4
+ swagger_api (0.2.8)
5
5
  active_attr
6
6
  rails (>= 5.0)
7
7
  rspec-rails
@@ -192,4 +192,4 @@ DEPENDENCIES
192
192
  webmock
193
193
 
194
194
  BUNDLED WITH
195
- 1.16.1
195
+ 1.16.2
data/README.md CHANGED
@@ -23,8 +23,56 @@ Or install it yourself as:
23
23
  Create a swagger.yml and place it in you gem directory (see swagger.yml in root directory for an example)
24
24
 
25
25
  $ bundle exec rake swagger:api
26
-
27
- This will create
26
+
27
+ This will create
28
+
29
+ ## Format of swagger.yml
30
+
31
+ ```yaml
32
+ info:
33
+ version: 0.0.1
34
+ title: FooService
35
+ description: Controls the CRUD of Foo
36
+ servers: # List of your API endpoints
37
+ test: # Rails.env
38
+ url: https://foo.example.com/api/foobar
39
+ controllers:
40
+ # This first format is the simplest and uses just the schema and validators to define the api
41
+ - name: FooController # controller class
42
+ model: Foo # model class associated with controller
43
+ actions: # Optional: field to define which actions this endpoint responds to
44
+ # the following two fields (only, except) are mutually exclusive. Choose one.
45
+ only:
46
+ - index
47
+ - update
48
+ except:
49
+ - update
50
+ columns: # Optional field to specify which params the api responds to. When using this specify at least one of the optional subfields.
51
+ # You must include at least one of the following 4 fields
52
+
53
+ # The following two fields (only, except) are mutually exclusive. Choose one.
54
+ only:
55
+ - column2
56
+ - column3
57
+ except:
58
+ - column3
59
+
60
+ virtual: # Defines virtual attributes. These do not exist in the associated model but are used by the controller.
61
+ - name: virtual1
62
+ schema:
63
+ type: integer
64
+ format: intg64
65
+ minimum: 1 # this field is only for integer types
66
+
67
+ required: # Defines additional fields as required even if there is not a validator associated with the field
68
+ - column4
69
+ - virtual1
70
+
71
+ - name: CustomsController
72
+ # Custom api json. You can use this gem to generate the base files from an existing model/controller and then modify as needed.
73
+ custom_model_file: api/custom_model.json
74
+ custom_path_file: api/custom_paths.json
75
+ ```
28
76
 
29
77
  ## Development
30
78
 
@@ -9,7 +9,7 @@ module SwaggerApi
9
9
  def create
10
10
  {
11
11
  required: required,
12
- properties: properties,
12
+ properties: properties.merge(virtual_properties),
13
13
  type: 'object'
14
14
  }
15
15
  end
@@ -51,6 +51,12 @@ module SwaggerApi
51
51
  end.compact.to_h
52
52
  end
53
53
 
54
+ def virtual_properties
55
+ (controller.try(:columns).try(:virtual) || []).map do |property|
56
+ [property.name, property.schema.to_h]
57
+ end.to_h
58
+ end
59
+
54
60
  def column_should_skip(column_name)
55
61
  column_name.end_with?('_iv') || absence_attributes.include?(column_name)
56
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SwaggerApi
4
- VERSION = '0.2.8'
4
+ VERSION = '0.2.9'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Full Measure Education
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-11 00:00:00.000000000 Z
11
+ date: 2018-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler