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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6d7e8bd82bb1384166a7b05b762bbfb31ae9940
4
- data.tar.gz: b4094c3b0020e510234ff13632a7be76728bd625
3
+ metadata.gz: bcc44f83fbfc033ffcb705294bfabe66ad77931f
4
+ data.tar.gz: 7a4246e624c0064d13d20cb69ab9596554e4c882
5
5
  SHA512:
6
- metadata.gz: 01b6da87aaa978797af17e081421136c01441d22048666beb8aa6baadc15698110e443b0a263dac0f85c4b45f18e12f5d168bdd35a988aa54cd3799e0d8b9ac2
7
- data.tar.gz: 9a8c5b69c3fbf57c17f44398f052ff994d1a640e3f7c0fcb2c54dc9ccfc4347ce1f80b5043f239244c1866ac421269294d367148ec81f0c9d5c0e54a4e66c940
6
+ metadata.gz: f976b31cefafbe77dcb69adc49319c903d559ed754770e1afff3c1a9a16a0e6568d260504024aad8878364fff90f25580aee38216518b42d6630b5a93d615678
7
+ data.tar.gz: a8f8ca363f696d796be24398b4d18da83abcb1cfcfd1e9da6eab9018f2caea4d4577402d077d7aff563de2974066bd04605f52a32312a499bb89fe3caf56a81c
data/MIT-LICENSE CHANGED
@@ -1,4 +1,5 @@
1
- Copyright 2013 Chris Trinh
1
+ Copyright (c) 2016 LivingSocial
2
+ Copyright (c) 2013 Chris Trinh
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining
4
5
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # SwaggerYard [![Build Status](https://travis-ci.org/tpitale/swagger_yard.svg?branch=master)](https://travis-ci.org/tpitale/swagger_yard) #
1
+ # SwaggerYard [![Build Status](https://travis-ci.org/livingsocial/swagger_yard.svg?branch=master)](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/tpitale/swagger_yard-rails) project. This provides an engine to parse and render the json required for use by swagger-ui_rails.
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/tpitale/swagger_yard-rails)
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/tpitale/swagger-yard_rails
206
+ [swagger_yard-rails]: https://github.com/livingsocial/swagger_yard-rails
@@ -24,7 +24,7 @@ module SwaggerYard
24
24
  tags.each do |tag|
25
25
  case tag.tag_name
26
26
  when "model"
27
- @id = tag.text
27
+ @id = tag.text.gsub(/[^[:alnum:]_]+/, '_')
28
28
  when "property"
29
29
  @properties << Property.from_tag(tag)
30
30
  end
@@ -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
- @parameters << Parameter.from_path_param(name)
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
- @parameters << Parameter.from_yard_tag(tag, self)
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
@@ -1,3 +1,3 @@
1
1
  module SwaggerYard
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
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.1
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: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard