jdoc 0.3.0 → 0.3.1

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: 882fb1ca942392f3f55bac3f59a40cb5b5fe6305
4
- data.tar.gz: 273cefe1904b0e628430ff94716ccd8a7642ff0b
3
+ metadata.gz: 32fedb39817ea5f19c6fdd4f058715150348b50d
4
+ data.tar.gz: 046bbaaf9e08fb214ee5eca23c80c3f73ab34ebf
5
5
  SHA512:
6
- metadata.gz: 1c3bf5c1527a6a9e9c88e2fd16cc0c9c6c1d6504c920fb6346d783489b1ee89750e77ec8168ba93a9c38a74f87a9dcca5de7d00f3e347127bc1312c5d51e583a
7
- data.tar.gz: c377a2e9e92a1252d338b671161c7cb8be598dd849920972262e6dea7685470db14e0cbf3478e90353c92699996f01c28dfa7a89d8cd34cf52b03c2d1362bea7
6
+ metadata.gz: f67afb16cbcdea69460fd56253d371b84b84aacb88bdea7115331c8fd9e9b0f4633499cef1ed853f0691de56d569eb9834bc869b2211db05051b7a7c80f2515a
7
+ data.tar.gz: 521e04c49a756ae3e3e86058b0c070c49b67f3be906fd21adc8219516277352e1e81a808b352c92c75f39a7c8325c938106b3c922f0e6f1b218f1d7455f3cf5c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.3.1
2
+ * Add error handling for ExampleNotFound
3
+
1
4
  ## 0.3.0
2
5
  * Change example response status and body to PUT & DELETE requests
3
6
  * Improve request path example by resolving variable in path
@@ -62,6 +62,8 @@ module Jdoc
62
62
  else
63
63
  result
64
64
  end
65
+ rescue Jdoc::Link::ExampleNotFound => exception
66
+ abort("Error: #{exception.to_s}")
65
67
  end
66
68
 
67
69
  private
data/lib/jdoc/link.rb CHANGED
@@ -63,11 +63,18 @@ module Jdoc
63
63
  end
64
64
 
65
65
  # @returns [String] Path with embedded example variable
66
+ # @raise [Rack::Spec::Mock::ExampleNotFound]
66
67
  # @example
67
68
  # link.example_path #=> "GET /apps/1"
68
69
  def example_path
69
70
  @example_path ||= @raw_link.href.gsub(/{\((.+?)\)}/) do
70
- JsonPointer.evaluate(root_schema.data, CGI.unescape($1))["example"]
71
+ pointer = CGI.unescape($1)
72
+ value = JsonPointer.evaluate(root_schema.data, pointer)
73
+ if value && value["example"]
74
+ value["example"]
75
+ else
76
+ raise ExampleNotFound, "No example found for #{pointer}"
77
+ end
71
78
  end
72
79
  end
73
80
 
data/lib/jdoc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jdoc
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura