betterdocs 0.10.0 → 0.11.0

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
  SHA256:
3
- metadata.gz: 43905ca43e64e65668831fed2e7c0d2eb1e0380347948c1d6f1aa7aa77bd8ea7
4
- data.tar.gz: 6c52dcacf3ca65b2111f5e1da6655af8ab728c20e552ee90ca953e547c490699
3
+ metadata.gz: ad6f53d72b6b1dc91c3464a277c97992814fcc8b34a55f1fd043ace97b58c27a
4
+ data.tar.gz: '0259b534dece36526365a0861d2750c5ac5c5446e24920ef4113f67d4f00103a'
5
5
  SHA512:
6
- metadata.gz: 493b9879a9c2bdcb1fd4d8858c59d34cf0a83eece18d15f1c7f005e84e57a127c101945c760cf0362d123b90006ecdcf2445a08cce586bd42cb882f4438d7df6
7
- data.tar.gz: 4de261093b3b6b0cb4541d99e4d572cb239f41ca9091fbb41b9a2fc6df5be4e33d5a499ded80a19ac0f4bb740cb8709297ae145ee01a407c4ed8166c9ccebc47
6
+ metadata.gz: 8489c381f2cff832c4552f109f05c15fe092b95ea688025e98ef987ea4c714425dd981897b177ad6ad49d046c3166b20fb1cf10ac517a564373ca8080172fc89
7
+ data.tar.gz: a9858527e935a0ed22f82f218907a4010ad86a523de7504afa55890bc4dfed66a00347cec4f0ebe0aa7dd8587ec43cee441623bb874ae2686e86316a11725c06
data/.tool-versions CHANGED
@@ -1,2 +1,2 @@
1
- ruby 3.1.2
1
+ ruby 3.1.3
2
2
  bundler 2.3.17
data/README.md CHANGED
@@ -22,6 +22,8 @@ This api generator requires that you follow the [representer pattern](http://nic
22
22
 
23
23
  ## Controller
24
24
 
25
+ betterdocs comes with a DSL for the (Rails) controllers - see examples below.
26
+
25
27
  ```ruby
26
28
  class ThingsController < ApplicationController
27
29
  # :nocov: Documentation
@@ -99,6 +101,7 @@ module ThingsRepresenter
99
101
  example 'my_name'
100
102
  end
101
103
 
104
+ # Add a link to the links list in the resulting JSON.
102
105
  link :self do
103
106
  description to <<-end
104
107
  Link to this resource itself
@@ -109,6 +112,12 @@ module ThingsRepresenter
109
112
  end
110
113
  ```
111
114
 
115
+ GENERATING
116
+ ----------
117
+
118
+ `rake doc:api:push` will push the documentation onto a git branch.
119
+ `rake doc:api:swagger` will call Swagger.
120
+
112
121
  RELEASING
113
122
  ---------
114
123
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.0
1
+ 0.11.0
data/betterdocs.gemspec CHANGED
@@ -1,21 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: betterdocs 0.10.0 ruby lib
2
+ # stub: betterdocs 0.11.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "betterdocs".freeze
6
- s.version = "0.10.0"
6
+ s.version = "0.11.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["betterplace Developers".freeze]
11
- s.date = "2022-08-16"
11
+ s.date = "2022-12-07"
12
12
  s.description = "This library provides tools to generate API documention for a web site's REST-ful JSON API.".freeze
13
13
  s.email = "developers@betterplace.org".freeze
14
14
  s.extra_rdoc_files = ["README.md".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/generator/swagger.rb".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/sanitizer.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/version.rb".freeze]
15
15
  s.files = [".codeclimate.yml".freeze, ".gitignore".freeze, ".rspec".freeze, ".semaphore/semaphore.yml".freeze, ".tool-versions".freeze, ".vscode/settings.json".freeze, "COPYING".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "betterdocs.gemspec".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/generator/markdown/templates/README.md.erb".freeze, "lib/betterdocs/generator/markdown/templates/section.md.erb".freeze, "lib/betterdocs/generator/swagger.rb".freeze, "lib/betterdocs/generator/swagger_static/index.html".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/sanitizer.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/tasks/doc.rake".freeze, "lib/betterdocs/version.rb".freeze, "spec/assets/app/assets/images/logos/logo.png".freeze, "spec/assets/app/controllers/api/foos_controller.rb".freeze, "spec/assets/app/views/api_v4/documentation/assets/CHANGELOG.md".freeze, "spec/assets/config/betterdocs.yml".freeze, "spec/betterdocs/dsl/controller/action/param_spec.rb".freeze, "spec/betterdocs/dsl/controller/action/response_spec.rb".freeze, "spec/betterdocs/dsl/json_type_mapper_spec.rb".freeze, "spec/betterdocs/dsl/result/collection_property_spec.rb".freeze, "spec/betterdocs/dsl/result/link_spec.rb".freeze, "spec/betterdocs/dsl/result/property_spec.rb".freeze, "spec/betterdocs/generator/markdown_spec.rb".freeze, "spec/betterdocs/global_spec.rb".freeze, "spec/betterdocs/json_params_representer_spec.rb".freeze, "spec/betterdocs/result_representer_spec.rb".freeze, "spec/betterdocs/sanitizer_spec.rb".freeze, "spec/controller_dsl_spec.rb".freeze, "spec/result_representer_dsl_spec.rb".freeze, "spec/spec_helper.rb".freeze]
16
16
  s.homepage = "https://github.com/betterplace/betterdocs".freeze
17
17
  s.rdoc_options = ["--title".freeze, "Betterdocs".freeze, "--main".freeze, "README.md".freeze]
18
- s.rubygems_version = "3.3.19".freeze
18
+ s.rubygems_version = "3.3.26".freeze
19
19
  s.summary = "Betterplace API documentation library".freeze
20
20
  s.test_files = ["spec/assets/app/controllers/api/foos_controller.rb".freeze, "spec/betterdocs/dsl/controller/action/param_spec.rb".freeze, "spec/betterdocs/dsl/controller/action/response_spec.rb".freeze, "spec/betterdocs/dsl/json_type_mapper_spec.rb".freeze, "spec/betterdocs/dsl/result/collection_property_spec.rb".freeze, "spec/betterdocs/dsl/result/link_spec.rb".freeze, "spec/betterdocs/dsl/result/property_spec.rb".freeze, "spec/betterdocs/generator/markdown_spec.rb".freeze, "spec/betterdocs/global_spec.rb".freeze, "spec/betterdocs/json_params_representer_spec.rb".freeze, "spec/betterdocs/result_representer_spec.rb".freeze, "spec/betterdocs/sanitizer_spec.rb".freeze, "spec/controller_dsl_spec.rb".freeze, "spec/result_representer_dsl_spec.rb".freeze, "spec/spec_helper.rb".freeze]
21
21
 
@@ -17,8 +17,12 @@ class Betterdocs::Dsl::Controller::Action::Response
17
17
 
18
18
  def data
19
19
  @data ||= instance_eval(&@data_block)
20
+ if hash = @data.ask_and_send(:to_hash)
21
+ hash[:data].present? or raise Error, "result for #{controller}##{action} is empty"
22
+ end
23
+ @data
20
24
  rescue => e
21
- error = Error.new("#{e.class}: #{e}")
25
+ error = e.is_a?(Error) ? e : Error.new("#{e.class}: #{e}")
22
26
  error.set_backtrace e.backtrace.grep(/^#{Betterdocs.rails.root}/)
23
27
  raise error
24
28
  end
@@ -1,6 +1,6 @@
1
1
  module Betterdocs
2
2
  # Betterdocs version
3
- VERSION = '0.10.0'
3
+ VERSION = '0.11.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -17,15 +17,18 @@ describe Betterdocs::Dsl::Controller::Action::Response do
17
17
  double(
18
18
  'Result',
19
19
  representer: representer,
20
- to_json: '{ "the": "result" }'
20
+ to_hash: { data: %w[ fake-it ] }
21
21
  )
22
22
  end
23
23
 
24
24
  let :response do
25
25
  data = result_data
26
- described_class.new do
26
+ object = described_class.new do
27
27
  data
28
28
  end
29
+ allow(object).to receive(:controller).and_return('TheController')
30
+ allow(object).to receive(:action).and_return('in_action')
31
+ object
29
32
  end
30
33
 
31
34
  let :param_value do
@@ -37,6 +40,11 @@ describe Betterdocs::Dsl::Controller::Action::Response do
37
40
  expect(response.params[:test]).to eq 'foo'
38
41
  end
39
42
 
43
+ it 'complains about missing data in example responses' do
44
+ allow(result_data).to receive(:to_hash).and_return('data' => [])
45
+ expect { response.data }.to raise_error(Betterdocs::Dsl::Controller::Action::Response::Error)
46
+ end
47
+
40
48
  it 'has data' do
41
49
  expect(response.data).to eq result_data
42
50
  end
@@ -54,6 +62,6 @@ describe Betterdocs::Dsl::Controller::Action::Response do
54
62
  end
55
63
 
56
64
  it 'can be converted into a JSON document' do
57
- expect(response.to_json).to eq '{ "the": "result" }'
65
+ expect(JSON(response.to_json)).to eq("data" => %w[ fake-it ])
58
66
  end
59
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betterdocs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - betterplace Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-16 00:00:00.000000000 Z
11
+ date: 2022-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -297,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
297
  - !ruby/object:Gem::Version
298
298
  version: '0'
299
299
  requirements: []
300
- rubygems_version: 3.3.19
300
+ rubygems_version: 3.3.26
301
301
  signing_key:
302
302
  specification_version: 4
303
303
  summary: Betterplace API documentation library