swagger_yard 0.3.1 → 0.3.2
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/MIT-LICENSE +2 -1
- data/README.md +4 -4
- data/lib/swagger_yard/model.rb +1 -1
- data/lib/swagger_yard/operation.rb +13 -2
- data/lib/swagger_yard/parameter.rb +8 -3
- data/lib/swagger_yard/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: bcc44f83fbfc033ffcb705294bfabe66ad77931f
|
4
|
+
data.tar.gz: 7a4246e624c0064d13d20cb69ab9596554e4c882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f976b31cefafbe77dcb69adc49319c903d559ed754770e1afff3c1a9a16a0e6568d260504024aad8878364fff90f25580aee38216518b42d6630b5a93d615678
|
7
|
+
data.tar.gz: a8f8ca363f696d796be24398b4d18da83abcb1cfcfd1e9da6eab9018f2caea4d4577402d077d7aff563de2974066bd04605f52a32312a499bb89fe3caf56a81c
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# SwaggerYard [](https://travis-ci.org/tpitale/swagger_yard) #
|
2
2
|
|
3
3
|
SwaggerYard is a gem to convert extended YARD syntax comments into the swagger spec compliant json format.
|
4
4
|
|
@@ -155,12 +155,12 @@ end
|
|
155
155
|
|
156
156
|
We suggest using something like [swagger-ui_rails](https://github.com/3scale/swagger-ui_rails/tree/dev-2.1.3) for your UI needs inside of Rails.
|
157
157
|
|
158
|
-
To generate JSON from your code on request, checkout the [swagger_yard-rails](https://github.com/
|
158
|
+
To generate JSON from your code on request, checkout the [swagger_yard-rails](https://github.com/livingsocial/swagger_yard-rails) project. This provides an engine to parse and render the json required for use by swagger-ui_rails.
|
159
159
|
|
160
160
|
## More Information ##
|
161
161
|
|
162
162
|
* [swagger-ui_rails](https://github.com/3scale/swagger-ui_rails/tree/dev-2.1.3)
|
163
|
-
* [swagger_yard-rails](https://github.com/
|
163
|
+
* [swagger_yard-rails](https://github.com/livingsocial/swagger_yard-rails)
|
164
164
|
* [Swagger-spec version 2.0](https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md)
|
165
165
|
* [Yard](https://github.com/lsegal/yard)
|
166
166
|
|
@@ -203,4 +203,4 @@ end
|
|
203
203
|
In [swagger_yard-rails][], this hook is used to set a function that inspects the
|
204
204
|
Rails routing tables to reverse look up and compute paths.
|
205
205
|
|
206
|
-
[swagger_yard-rails]: https://github.com/
|
206
|
+
[swagger_yard-rails]: https://github.com/livingsocial/swagger_yard-rails
|
data/lib/swagger_yard/model.rb
CHANGED
@@ -83,7 +83,7 @@ module SwaggerYard
|
|
83
83
|
@http_method = tag.types.first
|
84
84
|
|
85
85
|
parse_path_params(tag.text).each do |name|
|
86
|
-
|
86
|
+
add_or_update_parameter Parameter.from_path_param(name)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -93,7 +93,18 @@ module SwaggerYard
|
|
93
93
|
# Example: [Array] status(required, body) Filter by status. (e.g. status[]=1&status[]=2&status[]=3)
|
94
94
|
# Example: [Integer] media[media_type_id] ID of the desired media type.
|
95
95
|
def add_parameter(tag)
|
96
|
-
|
96
|
+
add_or_update_parameter Parameter.from_yard_tag(tag, self)
|
97
|
+
end
|
98
|
+
|
99
|
+
def add_or_update_parameter(parameter)
|
100
|
+
if existing = @parameters.detect {|param| param.name == parameter.name }
|
101
|
+
existing.description = parameter.description unless parameter.from_path?
|
102
|
+
existing.param_type = parameter.param_type if parameter.from_path?
|
103
|
+
existing.required ||= parameter.required
|
104
|
+
existing.allow_multiple = parameter.allow_multiple
|
105
|
+
else
|
106
|
+
@parameters << parameter
|
107
|
+
end
|
97
108
|
end
|
98
109
|
|
99
110
|
##
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module SwaggerYard
|
2
2
|
class Parameter
|
3
|
-
attr_accessor :name, :description
|
4
|
-
attr_reader :param_type, :required, :allow_multiple
|
3
|
+
attr_accessor :name, :description, :param_type, :required, :allow_multiple
|
5
4
|
|
6
5
|
def self.from_yard_tag(tag, operation)
|
7
6
|
description = tag.text
|
@@ -28,7 +27,8 @@ module SwaggerYard
|
|
28
27
|
new(name, Type.new("string"), "Scope response to #{name}", {
|
29
28
|
required: true,
|
30
29
|
allow_multiple: false,
|
31
|
-
param_type: "path"
|
30
|
+
param_type: "path",
|
31
|
+
from_path: true
|
32
32
|
})
|
33
33
|
end
|
34
34
|
|
@@ -38,6 +38,11 @@ module SwaggerYard
|
|
38
38
|
@required = options[:required] || false
|
39
39
|
@param_type = options[:param_type] || 'query'
|
40
40
|
@allow_multiple = options[:allow_multiple] || false
|
41
|
+
@from_path = options[:from_path] || false
|
42
|
+
end
|
43
|
+
|
44
|
+
def from_path?
|
45
|
+
@from_path
|
41
46
|
end
|
42
47
|
|
43
48
|
def to_h
|
data/lib/swagger_yard/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger_yard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chtrinh (Chris Trinh)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|