jdoc 0.1.2 → 0.1.3

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: 7cd0e286ca9d1efc9fd8d73dfbe5bef85e6d0da3
4
- data.tar.gz: 12a87a0a889e7140bb80eda2b12e1ef35ca18639
3
+ metadata.gz: 272ba27b2c8096ee1cd29cf122bc4a3ad0ab1ce7
4
+ data.tar.gz: 132c4ab5391930817097b13e3e98a66fbe8c7ff6
5
5
  SHA512:
6
- metadata.gz: 023a5f58f9ceeca9f7ace02c539ac48f2ff5b96773705c2700ce1d252d8c7bd0dbea3d3b3c1eac2c52d074f500f02196e4d10c2219737dc4849e4747727b1875
7
- data.tar.gz: 10d23acea805ea18bc88e32c4db87078e78c82d1d5abe70198c20182876a14e311ab77e53f1dd2991352e3bb8dd33ac58da2fb55d806c17645bf01341050cbe8
6
+ metadata.gz: 9366989f68722a5a3cbe9f1b43ae5dc1b59453e461d7196f46a85feacdd1318e3a7cb2f1abfca5550bc0991fe1b48588ac3d6272a98f709368c50f7c71667859
7
+ data.tar.gz: 07e0d09dc49e06766e90a3066698a3ce8def4f1e8956906cb5d666a1d1d7b6c9c003d40b6d7cc7122e245a9f8449d4741505a94f04c333835f151ed6e738e1b1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.1.3
2
+ * Use its pointer name if a resource has no title property
3
+
1
4
  ## 0.1.2
2
5
  * Use .schema property for request body if exists
3
6
  * Improve array resource handling
@@ -66,7 +66,6 @@ Delete an existing app.
66
66
 
67
67
  ```
68
68
  DELETE /apps/:id HTTP/1.1
69
- Content-Type: application/json
70
69
  Host: api.example.com
71
70
  ```
72
71
 
@@ -92,7 +91,6 @@ Info for existing app.
92
91
 
93
92
  ```
94
93
  GET /apps/:id HTTP/1.1
95
- Content-Type: application/json
96
94
  Host: api.example.com
97
95
  ```
98
96
 
@@ -118,7 +116,6 @@ List existing apps.
118
116
 
119
117
  ```
120
118
  GET /apps HTTP/1.1
121
- Content-Type: application/json
122
119
  Host: api.example.com
123
120
  ```
124
121
 
@@ -186,7 +183,6 @@ List recipes
186
183
 
187
184
  ```
188
185
  GET /recipes HTTP/1.1
189
- Content-Type: application/json
190
186
  Host: api.example.com
191
187
  ```
192
188
 
data/jdoc.gemspec CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
+ spec.add_dependency "activesupport"
19
20
  spec.add_dependency "erubis"
20
21
  spec.add_dependency "json_schema"
21
- spec.add_development_dependency "activesupport"
22
22
  spec.add_development_dependency "bundler", "~> 1.6"
23
23
  spec.add_development_dependency "pry"
24
24
  spec.add_development_dependency "rake"
data/lib/jdoc/link.rb CHANGED
@@ -147,7 +147,7 @@ module Jdoc
147
147
  # @param properties [Hash]
148
148
  # @return [Hash]
149
149
  # @example
150
- # Jdoc::Link::ResponseGenerator(schema.properties) #=> { "id" => 1, "name" => "example" }
150
+ # Jdoc::Link::ResponseGenerator(properties) #=> { "id" => 1, "name" => "example" }
151
151
  def self.call(properties)
152
152
  properties.inject({}) do |result, (key, value)|
153
153
  result.merge(
@@ -161,7 +161,7 @@ module Jdoc
161
161
  when value.type.include?("array")
162
162
  [call(value.items.properties)]
163
163
  else
164
- raise ExampleNotFound, "No example found for #{schema.pointer}/#{key}"
164
+ raise ExampleNotFound, "No example found for #{value.pointer}"
165
165
  end
166
166
  )
167
167
  end
data/lib/jdoc/resource.rb CHANGED
@@ -32,7 +32,7 @@ module Jdoc
32
32
  # @example
33
33
  # resource.title #=> "App"
34
34
  def title
35
- @schema.title
35
+ @title ||= @schema.title || @schema.pointer.split("/").last.camelize
36
36
  end
37
37
 
38
38
  # @return [Array<Jdoc::Property>]
@@ -44,16 +44,16 @@ module Jdoc
44
44
 
45
45
  # Defined to change uniqueness in Hash key
46
46
  def hash
47
- @schema.title.hash
47
+ title.hash
48
48
  end
49
49
 
50
50
  # Defined to change uniqueness in Hash key
51
51
  def eql?(other)
52
- @schema.title == other.title
52
+ title == other.title
53
53
  end
54
54
 
55
55
  def <=>(other)
56
- @schema.title <=> other.title
56
+ title <=> other.title
57
57
  end
58
58
 
59
59
  def links
data/lib/jdoc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jdoc
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/jdoc.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "active_support/core_ext/string/inflections"
1
2
  require "cgi"
2
3
  require "erubis"
3
4
  require "json_schema"
@@ -87,7 +87,6 @@ definitions:
87
87
  items:
88
88
  "$ref": "#/definitions/user"
89
89
  recipe:
90
- title: Recipe
91
90
  type: object
92
91
  definitions:
93
92
  name:
data/template.md.erb CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  ```
26
26
  <%= link.method %> <%= link.path %> HTTP/1.1
27
- Content-Type: application/json
27
+ <%= "Content-Type: application/json\n" if link.has_request_body? -%>
28
28
  Host: <%= schema.host_with_port %>
29
29
  <%= "\n" + link.request_body if link.has_request_body? -%>
30
30
  ```
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-19 00:00:00.000000000 Z
11
+ date: 2014-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: erubis
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: json_schema
28
+ name: erubis
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,13 +39,13 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activesupport
42
+ name: json_schema
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :development
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements: