rspec-api-docs 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/Rakefile +6 -1
- data/bin/generate_integration_docs +3 -1
- data/lib/rspec_api_docs.rb +1 -0
- data/lib/rspec_api_docs/config.rb +1 -0
- data/lib/rspec_api_docs/dsl/doc_proxy.rb +14 -0
- data/lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb +1 -0
- data/lib/rspec_api_docs/formatter/renderer/raddocs_renderer/resource_serializer.rb +2 -2
- data/lib/rspec_api_docs/formatter/resource/example.rb +5 -0
- data/lib/rspec_api_docs/formatter/resource/parameter.rb +2 -2
- data/lib/rspec_api_docs/formatter/resource/response_field.rb +2 -2
- data/lib/rspec_api_docs/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: e7e5799e512fca99e136a0909ba2118a90d96073
|
4
|
+
data.tar.gz: 48de8b3f91fa45947fc1903fe25b0e4b8351aa93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adac7650aa8fbd77ae177ec13eb55173818a0c48cf725795bbc0fa8821a98c7e9b375cc3418b0df1b668cd508cdad26c83b39e578c1ba76d2400235cbc7478e5
|
7
|
+
data.tar.gz: 12f01cf8d991c15c98b5d05b9a452f0ea2e915049160337b8ef5ef39510b356af4ece8d43096aa80cdb2935e564f4394ca06599269c3fd5115e0efdac551f74f
|
data/README.md
CHANGED
@@ -207,6 +207,18 @@ param :id, 'The id of a character', scope: :character, type: 'integer', required
|
|
207
207
|
param :name, "The character's name", scope: :character, type: 'string'
|
208
208
|
```
|
209
209
|
|
210
|
+
#### `notes`
|
211
|
+
|
212
|
+
Accepts a `note` and optional `level`.
|
213
|
+
|
214
|
+
- `level` [`Symbol`] one of `:success`, `:info`, `:warning`, or `:danger`. Defaults to `:info`
|
215
|
+
- `note` [`String`] the note
|
216
|
+
|
217
|
+
``` ruby
|
218
|
+
note 'You need to supply an id!'
|
219
|
+
note :warning, "An error will be thrown if you don't supply an id!"
|
220
|
+
```
|
221
|
+
|
210
222
|
See the integration specs for more examples of the DSL in use.
|
211
223
|
|
212
224
|
### Formatter
|
data/Rakefile
CHANGED
@@ -10,4 +10,9 @@ RuboCop::RakeTask.new :rubocop do |task|
|
|
10
10
|
task.verbose = false
|
11
11
|
end
|
12
12
|
|
13
|
-
task
|
13
|
+
task :generate_integration_docs do
|
14
|
+
system './bin/generate_integration_docs'
|
15
|
+
exit $?.exitstatus
|
16
|
+
end
|
17
|
+
|
18
|
+
task default: [:rspec, :rubocop, :generate_integration_docs]
|
data/lib/rspec_api_docs.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module RspecApiDocs
|
2
2
|
module Dsl
|
3
3
|
class DocProxy
|
4
|
+
UnknownNoteLevel = Class.new(BaseError)
|
5
|
+
|
4
6
|
attr_reader :metadata
|
5
7
|
|
6
8
|
def initialize(example)
|
@@ -112,6 +114,18 @@ module RspecApiDocs
|
|
112
114
|
required: required,
|
113
115
|
}
|
114
116
|
end
|
117
|
+
|
118
|
+
# For setting notes on an example
|
119
|
+
#
|
120
|
+
# @param level [Symbol] the level of the note
|
121
|
+
# @param value [String] the note, +:success+, +:info+, +:warning+, or +:danger+
|
122
|
+
# @return [void]
|
123
|
+
def note(level = :info, value)
|
124
|
+
%i[success info warning danger].include?(level) or
|
125
|
+
raise UnknownNoteLevel, "unknown note level #{level.inspect}"
|
126
|
+
metadata[METADATA_NAMESPACE][:note] ||= {}
|
127
|
+
metadata[METADATA_NAMESPACE][:note][level] = value
|
128
|
+
end
|
115
129
|
end
|
116
130
|
end
|
117
131
|
end
|
@@ -33,7 +33,7 @@ module RspecApiDocs
|
|
33
33
|
parameters.map do |parameter|
|
34
34
|
result = {}
|
35
35
|
result[:required] = true if parameter.required
|
36
|
-
result[:scope] = parameter.scope
|
36
|
+
result[:scope] = parameter.scope.join
|
37
37
|
result = result.merge(
|
38
38
|
name: parameter.name,
|
39
39
|
description: parameter.description,
|
@@ -45,7 +45,7 @@ module RspecApiDocs
|
|
45
45
|
def response_fields(fields)
|
46
46
|
fields.map do |field|
|
47
47
|
{
|
48
|
-
scope: field.scope,
|
48
|
+
scope: field.scope.join,
|
49
49
|
Type: field.type,
|
50
50
|
name: field.name,
|
51
51
|
description: field.description,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-api-docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Odin Dutton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|