lurker 0.6.0 → 0.6.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.hound.yml +15 -0
- data/.rubocop.yml +15 -0
- data/README.md +19 -4
- data/Rakefile +1 -1
- data/certs/razum2um.pem +21 -0
- data/features/atom_persistent_within_the_same_type.feature +138 -0
- data/features/controller_schema_scaffolding.feature +5 -1
- data/features/multitype_request_support.feature +139 -0
- data/features/request_schema_scaffolding.feature +6 -4
- data/features/schema_updating_within_test_suite.feature +138 -0
- data/features/test_endpoint.feature +6 -3
- data/lib/lurker.rb +20 -4
- data/lib/lurker/cli.rb +2 -3
- data/lib/lurker/endpoint.rb +63 -28
- data/lib/lurker/presenters/endpoint_presenter.rb +10 -4
- data/lib/lurker/schema.rb +14 -16
- data/lib/lurker/schema_modifier.rb +46 -0
- data/lib/lurker/schema_modifier/array.rb +28 -0
- data/lib/lurker/schema_modifier/atom.rb +88 -0
- data/lib/lurker/schema_modifier/hash.rb +30 -0
- data/lib/lurker/service.rb +2 -6
- data/lib/lurker/spy.rb +1 -1
- data/lib/lurker/templates/layouts/application.html.erb +1 -0
- data/lib/lurker/version.rb +1 -1
- data/lurker.gemspec +13 -10
- data/templates/generate_stuff.rb +25 -3
- data/templates/lurker_app.rb +17 -2
- metadata +135 -68
- metadata.gz.sig +2 -0
- checksums.yaml.gz.asc +0 -12
- data.tar.gz.asc +0 -12
- data/lib/lurker/endpoint_scaffold.rb +0 -135
- metadata.gz.asc +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a914bcb615ccfdd4b68d8596ddf908d406003045
|
4
|
+
data.tar.gz: 0914a12a0879b48ee724accf0e574ee52c4de24c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a2e411348e7c483a2d9984dabd476a6136bfcad6c9cef8b42afa7288149f447505e86d0fe77fbb578f70bd414a65057c6a8a1f1b5cd23871393d70b88cd8a06
|
7
|
+
data.tar.gz: 81e866b271eb19fd2550865e4b6998c20f3717237060ca24b55343b90adc4e65e1e1ea445cad32dd32b20e020fd1b4b1b5cc4a1c4806c52d7846aef88f5b110d
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/.hound.yml
ADDED
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -10,11 +10,18 @@ Works on Rails 3.2, 4.0, 4.1 & Ruby 1.9.3, 2.0.0, 2.1.1.
|
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
|
-
Add
|
13
|
+
Add my public key:
|
14
|
+
|
15
|
+
gem cert --add <(curl -Ls https://raw.github.com/razum2um/lurker/master/certs/razum2um.pem)
|
16
|
+
|
17
|
+
$ gem install lurker # without key
|
18
|
+
$ gem install lurker -P HighSecurity # secure, with key added
|
19
|
+
|
20
|
+
Or this line to your application's Gemfile:
|
14
21
|
|
15
22
|
gem 'lurker'
|
16
23
|
|
17
|
-
|
24
|
+
Inject into `test_helper.rb` or `spec_helper.rb`:
|
18
25
|
|
19
26
|
require 'lurker/spec_helper'
|
20
27
|
|
@@ -77,6 +84,12 @@ and it fails if your code changes the api!
|
|
77
84
|
- The property '#/user/last_sign_in_at' of type String did not match the following type:
|
78
85
|
null in schema file:///.../lurker/api/v1/users-POST.json.yml#
|
79
86
|
|
87
|
+
The generation of live-documentation is pretty simple:
|
88
|
+
|
89
|
+
bin/lurker convert # builds html under `Rails.root/html`
|
90
|
+
bin/lurker convert -o public/lurker # builds html under `Rails.root/public/lurker`
|
91
|
+
bin/lurker convert -f pdf -o html # builds `ServiceName.pdf` under `Rails.root/html`
|
92
|
+
|
80
93
|
Let's run your `rails s` and visit [http://localhost:3000/lurker/](http://localhost:3000/lurker/)
|
81
94
|
(or see [demo][demo_app2] for example)
|
82
95
|
|
@@ -104,10 +117,12 @@ For example:
|
|
104
117
|
- [Pretty submit form to test API endpoints (live) based on schemas][demo_live] (enter a name & press "Submit")
|
105
118
|
- [Handling URLs with dynamic segments][nested_controller_spec_example] (such as `api/v1/:user_id/repos`)
|
106
119
|
- [JSON-Schema partials][partial_example], also in YAML format ([demo][partial_example_demo])
|
107
|
-
- [Generation PDF documentation][pdf_example]
|
120
|
+
- [Generation PDF documentation][pdf_example] (add `gem 'pdfkit'` to Gemfile)
|
108
121
|
- [Multiple docs for many usecases][suffixes_example] (e.g `:lurker => '...'`)
|
109
122
|
- ERB support inside `.json.yml.erb`
|
110
|
-
-
|
123
|
+
- Insert custom content in Markdown into `index.html` (add `gem 'kramdown'` to Gemfile)
|
124
|
+
- Syntax highlighting for sample response (add `gem 'execjs'` to Gemfile)
|
125
|
+
- HTTP-Auth authorization for docs (`mount Lurker::Server.to_rack username: '...', password: '...'`)
|
111
126
|
- Separate API-services generated within one test suite
|
112
127
|
- Capistrano integration
|
113
128
|
- JSON-Schema draft-v4 support
|
data/Rakefile
CHANGED
@@ -302,7 +302,7 @@ task :publish do
|
|
302
302
|
system "git tag v#{version}"
|
303
303
|
system "relish versions:add razum2um/lurker:#{version}"
|
304
304
|
system "relish push razum2um/lurker:#{version}"
|
305
|
-
system "gem build lurker.gemspec
|
305
|
+
system "gem build lurker.gemspec"
|
306
306
|
system "git push --tags"
|
307
307
|
system "gem push lurker-#{version}.gem"
|
308
308
|
end
|
data/certs/razum2um.pem
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApib2tv
|
3
|
+
di52bGFkMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
|
4
|
+
b20wHhcNMTQw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|
+
vzKbYclpJ7gENr/xiTjGqA/Md3zJMzmsFrzUXt4RVmo5SaCyZjC6gFfhSr+PODc7
|
20
|
+
ZaSbckvH/+m4boAsg0JkGGFcS3j5fgNmdwgA1A==
|
21
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,138 @@
|
|
1
|
+
Feature: atom persistent within test suite
|
2
|
+
Background:
|
3
|
+
Given a file named "lurker/api/v2/users/__id-PATCH.json.yml" with:
|
4
|
+
"""yml
|
5
|
+
---
|
6
|
+
description: user updating
|
7
|
+
prefix: users management
|
8
|
+
requestParameters:
|
9
|
+
description: ''
|
10
|
+
type: object
|
11
|
+
additionalProperties: false
|
12
|
+
required: []
|
13
|
+
properties:
|
14
|
+
user:
|
15
|
+
description: ''
|
16
|
+
type: object
|
17
|
+
additionalProperties: false
|
18
|
+
required: []
|
19
|
+
properties:
|
20
|
+
name:
|
21
|
+
description: ''
|
22
|
+
type: string
|
23
|
+
example: NameIsPersistentInExaple
|
24
|
+
surname:
|
25
|
+
description: ''
|
26
|
+
type: string
|
27
|
+
example: SurnameIsPersistentInExaple
|
28
|
+
responseCodes:
|
29
|
+
- status: 200
|
30
|
+
successful: true
|
31
|
+
description: ''
|
32
|
+
responseParameters:
|
33
|
+
description: ''
|
34
|
+
type: object
|
35
|
+
additionalProperties: false
|
36
|
+
required: []
|
37
|
+
properties:
|
38
|
+
id:
|
39
|
+
description: ''
|
40
|
+
type: integer
|
41
|
+
example: 100
|
42
|
+
name:
|
43
|
+
description: ''
|
44
|
+
type: string
|
45
|
+
example: NameIsPersistentInExaple
|
46
|
+
surname:
|
47
|
+
description: ''
|
48
|
+
type: string
|
49
|
+
example: SurnameIsPersistentInExaple
|
50
|
+
extensions:
|
51
|
+
method: PATCH
|
52
|
+
path_info: "/api/v2/users/100"
|
53
|
+
path_params:
|
54
|
+
id: '100'
|
55
|
+
controller: api/v2/users
|
56
|
+
action: update
|
57
|
+
suffix: ''
|
58
|
+
"""
|
59
|
+
|
60
|
+
Scenario: json schema tests response parameters and keep atom unchanged using "users/update"
|
61
|
+
Given a file named "spec/controllers/api/v2/users_controller_spec.rb" with:
|
62
|
+
"""ruby
|
63
|
+
require "spec_helper"
|
64
|
+
|
65
|
+
describe Api::V2::UsersController, :lurker do
|
66
|
+
render_views
|
67
|
+
|
68
|
+
let(:user) do
|
69
|
+
User.where(name: 'razum2um', surname: 'Unknown').first_or_create!
|
70
|
+
end
|
71
|
+
|
72
|
+
it "updates a user surname as string" do
|
73
|
+
patch :update, id: user.id, user: { surname: 'Marley' }
|
74
|
+
expect(response).to be_success
|
75
|
+
end
|
76
|
+
end
|
77
|
+
"""
|
78
|
+
|
79
|
+
When I run `bin/rspec spec/controllers/api/v2/users_controller_spec.rb`
|
80
|
+
Then the example should pass
|
81
|
+
Then a file named "lurker/api/v2/users/__id-PATCH.json.yml" should exist
|
82
|
+
Then the file "lurker/api/v2/users/__id-PATCH.json.yml" should contain exactly:
|
83
|
+
"""yml
|
84
|
+
---
|
85
|
+
description: user updating
|
86
|
+
prefix: users management
|
87
|
+
requestParameters:
|
88
|
+
description: ''
|
89
|
+
type: object
|
90
|
+
additionalProperties: false
|
91
|
+
required: []
|
92
|
+
properties:
|
93
|
+
user:
|
94
|
+
description: ''
|
95
|
+
type: object
|
96
|
+
additionalProperties: false
|
97
|
+
required: []
|
98
|
+
properties:
|
99
|
+
name:
|
100
|
+
description: ''
|
101
|
+
type: string
|
102
|
+
example: NameIsPersistentInExaple
|
103
|
+
surname:
|
104
|
+
description: ''
|
105
|
+
type: string
|
106
|
+
example: SurnameIsPersistentInExaple
|
107
|
+
responseCodes:
|
108
|
+
- status: 200
|
109
|
+
successful: true
|
110
|
+
description: ''
|
111
|
+
responseParameters:
|
112
|
+
description: ''
|
113
|
+
type: object
|
114
|
+
additionalProperties: false
|
115
|
+
required: []
|
116
|
+
properties:
|
117
|
+
id:
|
118
|
+
description: ''
|
119
|
+
type: integer
|
120
|
+
example: 100
|
121
|
+
name:
|
122
|
+
description: ''
|
123
|
+
type: string
|
124
|
+
example: NameIsPersistentInExaple
|
125
|
+
surname:
|
126
|
+
description: ''
|
127
|
+
type: string
|
128
|
+
example: SurnameIsPersistentInExaple
|
129
|
+
extensions:
|
130
|
+
method: PATCH
|
131
|
+
path_info: "/api/v2/users/100"
|
132
|
+
path_params:
|
133
|
+
id: '100'
|
134
|
+
controller: api/v2/users
|
135
|
+
action: update
|
136
|
+
suffix: ''
|
137
|
+
|
138
|
+
"""
|
@@ -13,7 +13,7 @@ Feature: controller schema scaffolding
|
|
13
13
|
render_views
|
14
14
|
|
15
15
|
let!(:user) do
|
16
|
-
User.where(name: 'razum2um').first_or_create!
|
16
|
+
User.where(name: 'razum2um', surname: 'Marley').first_or_create!
|
17
17
|
end
|
18
18
|
|
19
19
|
it "shows user" do
|
@@ -55,6 +55,10 @@ Feature: controller schema scaffolding
|
|
55
55
|
description: ''
|
56
56
|
type: string
|
57
57
|
example: razum2um
|
58
|
+
surname:
|
59
|
+
description: ''
|
60
|
+
type: string
|
61
|
+
example: Marley
|
58
62
|
extensions:
|
59
63
|
method: GET
|
60
64
|
path_info: "/api/v1/users/1.json"
|
@@ -0,0 +1,139 @@
|
|
1
|
+
Feature: multitype request support
|
2
|
+
|
3
|
+
If your API add new type for the same request parameter
|
4
|
+
and the new code isn't breaking it
|
5
|
+
you'll see nothing special, just passing specs
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "lurker/api/v2/users/__id-PATCH.json.yml" with:
|
9
|
+
"""yml
|
10
|
+
---
|
11
|
+
description: user updating
|
12
|
+
prefix: users management
|
13
|
+
requestParameters:
|
14
|
+
description: ''
|
15
|
+
type: object
|
16
|
+
additionalProperties: false
|
17
|
+
required: []
|
18
|
+
properties:
|
19
|
+
user:
|
20
|
+
description: ''
|
21
|
+
type: object
|
22
|
+
additionalProperties: false
|
23
|
+
required: []
|
24
|
+
properties:
|
25
|
+
surname:
|
26
|
+
description: ''
|
27
|
+
type: integer
|
28
|
+
example: 42
|
29
|
+
responseCodes:
|
30
|
+
- status: 200
|
31
|
+
successful: true
|
32
|
+
description: ''
|
33
|
+
responseParameters:
|
34
|
+
description: ''
|
35
|
+
type: object
|
36
|
+
additionalProperties: false
|
37
|
+
required: []
|
38
|
+
properties:
|
39
|
+
id:
|
40
|
+
description: ''
|
41
|
+
type: integer
|
42
|
+
example: 1
|
43
|
+
name:
|
44
|
+
description: ''
|
45
|
+
type: string
|
46
|
+
example: razum2um
|
47
|
+
surname:
|
48
|
+
description: ''
|
49
|
+
type: string
|
50
|
+
example: Marley
|
51
|
+
extensions:
|
52
|
+
method: PATCH
|
53
|
+
path_info: "/api/v2/users/1"
|
54
|
+
path_params:
|
55
|
+
id: '1'
|
56
|
+
controller: api/v2/users
|
57
|
+
action: update
|
58
|
+
suffix: ''
|
59
|
+
"""
|
60
|
+
|
61
|
+
Scenario: json schema tests response parameters and update request parameters using "users/update"
|
62
|
+
Given a file named "spec/controllers/api/v2/users_controller_spec.rb" with:
|
63
|
+
"""ruby
|
64
|
+
require "spec_helper"
|
65
|
+
|
66
|
+
describe Api::V2::UsersController, :lurker do
|
67
|
+
render_views
|
68
|
+
|
69
|
+
let(:user) do
|
70
|
+
User.where(name: 'razum2um', surname: 'Unknown').first_or_create!
|
71
|
+
end
|
72
|
+
|
73
|
+
it "updates a user surname as string" do
|
74
|
+
patch :update, id: user.id, user: { surname: 'Marley' }
|
75
|
+
expect(response).to be_success
|
76
|
+
end
|
77
|
+
end
|
78
|
+
"""
|
79
|
+
|
80
|
+
When I run `bin/rspec spec/controllers/api/v2/users_controller_spec.rb`
|
81
|
+
Then the example should pass
|
82
|
+
Then a file named "lurker/api/v2/users/__id-PATCH.json.yml" should exist
|
83
|
+
Then the file "lurker/api/v2/users/__id-PATCH.json.yml" should contain exactly:
|
84
|
+
"""yml
|
85
|
+
---
|
86
|
+
description: user updating
|
87
|
+
prefix: users management
|
88
|
+
requestParameters:
|
89
|
+
description: ''
|
90
|
+
type: object
|
91
|
+
additionalProperties: false
|
92
|
+
required: []
|
93
|
+
properties:
|
94
|
+
user:
|
95
|
+
description: ''
|
96
|
+
type: object
|
97
|
+
additionalProperties: false
|
98
|
+
required: []
|
99
|
+
properties:
|
100
|
+
surname:
|
101
|
+
anyOf:
|
102
|
+
- description: ''
|
103
|
+
type: integer
|
104
|
+
example: 42
|
105
|
+
- description: ''
|
106
|
+
type: string
|
107
|
+
example: Marley
|
108
|
+
responseCodes:
|
109
|
+
- status: 200
|
110
|
+
successful: true
|
111
|
+
description: ''
|
112
|
+
responseParameters:
|
113
|
+
description: ''
|
114
|
+
type: object
|
115
|
+
additionalProperties: false
|
116
|
+
required: []
|
117
|
+
properties:
|
118
|
+
id:
|
119
|
+
description: ''
|
120
|
+
type: integer
|
121
|
+
example: 1
|
122
|
+
name:
|
123
|
+
description: ''
|
124
|
+
type: string
|
125
|
+
example: razum2um
|
126
|
+
surname:
|
127
|
+
description: ''
|
128
|
+
type: string
|
129
|
+
example: Marley
|
130
|
+
extensions:
|
131
|
+
method: PATCH
|
132
|
+
path_info: "/api/v2/users/1"
|
133
|
+
path_params:
|
134
|
+
id: '1'
|
135
|
+
controller: api/v2/users
|
136
|
+
action: update
|
137
|
+
suffix: ''
|
138
|
+
|
139
|
+
"""
|
@@ -11,11 +11,11 @@ Feature: request schema scaffolding
|
|
11
11
|
|
12
12
|
describe Api::V1::UsersController, :lurker do
|
13
13
|
let!(:user) do
|
14
|
-
User.where(name: 'razum2um').first_or_create!
|
14
|
+
User.where(name: 'razum2um', surname: 'Marley').first_or_create!
|
15
15
|
end
|
16
16
|
|
17
17
|
let!(:bot) do
|
18
|
-
User.where(name: 'bot').first_or_create!
|
18
|
+
User.where(name: 'bot', surname: 'google').first_or_create!
|
19
19
|
end
|
20
20
|
|
21
21
|
it "lists all the users" do
|
@@ -64,6 +64,10 @@ Feature: request schema scaffolding
|
|
64
64
|
description: ''
|
65
65
|
type: string
|
66
66
|
example: razum2um
|
67
|
+
surname:
|
68
|
+
description: ''
|
69
|
+
type: string
|
70
|
+
example: Marley
|
67
71
|
extensions:
|
68
72
|
method: GET
|
69
73
|
path_info: "/api/v1/users.json"
|
@@ -75,5 +79,3 @@ Feature: request schema scaffolding
|
|
75
79
|
suffix: ''
|
76
80
|
|
77
81
|
"""
|
78
|
-
|
79
|
-
|