swagger_docs_generator 0.3.6 → 0.4.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1acc55b2ce3bf7a00dd5181f202f40639ee86ae
|
4
|
+
data.tar.gz: baba1e428c1cf9df4195ff207cda25e94eab922a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93ea4e3b522dcf2d842f20a9a7f90ba809566abe4f1b63d7e93d3942310c2c6b95446402b71957a1c845f3f53ad121aa94e9e4358c945f8bb62d24424ee2eee1
|
7
|
+
data.tar.gz: ae86e26cf7d4a46915ca71d290c6b929f92bef02da20252bfc9d1cc17ef3fbcd431ac97b43b2cd72ced90eb8fabf84c866c8337395a627577be87b66b051cbc2
|
data/README.md
CHANGED
@@ -52,6 +52,104 @@ Execute rake task for generated `swagger.json` :
|
|
52
52
|
rake swagger:docs
|
53
53
|
```
|
54
54
|
|
55
|
+
|
56
|
+
## Examples
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
# frozen_string_literal: true
|
60
|
+
|
61
|
+
module V1
|
62
|
+
# Documentation API for AddressesController
|
63
|
+
class AddressesDoc < BaseDoc
|
64
|
+
CONTROLLER = V1::Geos::AddressesController
|
65
|
+
|
66
|
+
# Describe object Addresses
|
67
|
+
# ###
|
68
|
+
scontroller 'User Addresses management'
|
69
|
+
|
70
|
+
# Describe all actions
|
71
|
+
# ###
|
72
|
+
sdoc :show do
|
73
|
+
summary 'Show address'
|
74
|
+
responses do
|
75
|
+
status 200
|
76
|
+
schema { definition 'address' }
|
77
|
+
end
|
78
|
+
responses { status 404 }
|
79
|
+
responses { status 422 }
|
80
|
+
description <<EOS
|
81
|
+
# Show address to user
|
82
|
+
|
83
|
+
Show complete address to user.
|
84
|
+
EOS
|
85
|
+
end
|
86
|
+
|
87
|
+
sdoc :create do
|
88
|
+
summary 'Create address'
|
89
|
+
responses { status 201 }
|
90
|
+
responses { status 422 }
|
91
|
+
parameters do
|
92
|
+
body do
|
93
|
+
name 'address'
|
94
|
+
schema 'address create'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
description <<EOS
|
98
|
+
# Add address
|
99
|
+
|
100
|
+
Save an address to user.
|
101
|
+
EOS
|
102
|
+
end
|
103
|
+
|
104
|
+
sdoc :update do
|
105
|
+
summary 'Update address'
|
106
|
+
responses do
|
107
|
+
status 200
|
108
|
+
schema { definition 'address' }
|
109
|
+
end
|
110
|
+
responses { status 404 }
|
111
|
+
responses { status 422 }
|
112
|
+
end
|
113
|
+
|
114
|
+
sdoc :destroy do
|
115
|
+
summary 'Destroy address'
|
116
|
+
responses do
|
117
|
+
status 200
|
118
|
+
schema { definition 'address' }
|
119
|
+
end
|
120
|
+
responses { status 404 }
|
121
|
+
responses { status 422 }
|
122
|
+
end
|
123
|
+
|
124
|
+
# Add definition more model
|
125
|
+
# ###
|
126
|
+
sdefinition 'address create' do
|
127
|
+
required %w[address]
|
128
|
+
properties do
|
129
|
+
required %w{country city zip_code street}
|
130
|
+
properties country: { type: :string },
|
131
|
+
city: { type: :string },
|
132
|
+
zip_code: { type: :string },
|
133
|
+
street: { type: :string },
|
134
|
+
complements: { type: :string }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
sdefinition 'address' do
|
139
|
+
required %w[address]
|
140
|
+
properties do
|
141
|
+
properties country: { type: :string },
|
142
|
+
city: { type: :string },
|
143
|
+
zip_code: { type: :string },
|
144
|
+
street: { type: :string },
|
145
|
+
complements: { type: :string },
|
146
|
+
coordinates: { type: :string }
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
```
|
152
|
+
|
55
153
|
## Development
|
56
154
|
|
57
155
|
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
@@ -27,8 +27,12 @@ module SwaggerDocsGenerator
|
|
27
27
|
@type = text
|
28
28
|
end
|
29
29
|
|
30
|
-
def properties(text)
|
31
|
-
@properties =
|
30
|
+
def properties(text = nil, &block)
|
31
|
+
@properties = if block_given?
|
32
|
+
{ @required.first => SubProperties.new(&block).construct }
|
33
|
+
else
|
34
|
+
text
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
def required(text)
|
@@ -52,3 +56,5 @@ module SwaggerDocsGenerator
|
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
59
|
+
|
60
|
+
require 'swagger_docs_generator/parser/sub_definition'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :reek:InstanceVariableAssumption
|
4
|
+
module SwaggerDocsGenerator
|
5
|
+
# # Parse Controller classes
|
6
|
+
#
|
7
|
+
# Parse controller classes in Rails application. It's create temporary file
|
8
|
+
# and adding automaticaly tags element.
|
9
|
+
class SubProperties < ParserDefinition
|
10
|
+
def initialize(&block)
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def construct
|
15
|
+
{
|
16
|
+
type: @type || 'object',
|
17
|
+
required: @required || [],
|
18
|
+
properties: @properties
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def properties(text)
|
25
|
+
@properties = text
|
26
|
+
end
|
27
|
+
|
28
|
+
def type
|
29
|
+
'object'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger_docs_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VAILLANT Jeremy
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- lib/swagger_docs_generator/parser/definition.rb
|
273
273
|
- lib/swagger_docs_generator/parser/model.rb
|
274
274
|
- lib/swagger_docs_generator/parser/parser.rb
|
275
|
+
- lib/swagger_docs_generator/parser/sub_definition.rb
|
275
276
|
- lib/swagger_docs_generator/railtie.rb
|
276
277
|
- lib/tasks/swagger.rake
|
277
278
|
- spec/spec_helper.rb
|