swagger_api 0.2.8 → 0.2.9
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/Gemfile.lock +2 -2
- data/README.md +50 -2
- data/lib/swagger_api/component_schema.rb +7 -1
- data/lib/swagger_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cb3bbfda85e560abdea01543ed17e09a12dbbf4
|
|
4
|
+
data.tar.gz: 56c66db2c4a70c2ee4b134ab7da33d431d1ba973
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 940cf5e6d78cd653bfa1c9e43aab10f54ed88c32c573b4a6d39dafb76a3b3d6022855dea3e2726faafff02cd8dd8dc1cdee6308c8dfda1c77557b66e3a3e7403
|
|
7
|
+
data.tar.gz: ac3a1b68c7ea692fc6926dc8d1e34523980554850583a2b73cc26f7c2971165b6eeb4bc4a759cb6a018c24720bdfa99b98ff48c47838a79a70625aad9904e406
|
data/Gemfile.lock
CHANGED
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
|
data/lib/swagger_api/version.rb
CHANGED
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.
|
|
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
|
+
date: 2018-07-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|