swagger-blocks 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.travis.yml +1 -0
- data/README.md +13 -1
- data/lib/swagger/blocks/version.rb +1 -1
- data/lib/swagger/blocks.rb +5 -7
- data/swagger-blocks.gemspec +1 -1
- metadata +17 -18
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YmQyODUyY2U2NmY1MDExMjllYWNjOTE2ZTIxYmJiYTdkZTcyM2Q1Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZjUzZjViYWFkYTk0MGVkN2RmNWZlYWIzZjI1NzQ1MDUxNTIzYjA5Nw==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjI3MjA3YzM2Njc2MGJkYTY2YzViYjI4YTU1MWZmNDExZjllNDUxYjAyYzJl
|
10
|
+
YjRkZjM5NDJhNDIxYzcxZTJkMjRhNGRhMzFjNTNmZjBmZjUzNzg0Y2FkMTMz
|
11
|
+
YzIyODRlODdkM2Y4NWVkY2M0ZjYzNWY1ZjU3ZGI0MWE5MWVmODE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjQzZDFhYzllNmUyNDg0NTQ3NzgzYjI0ZTNmODdmMzBjN2I5MDU4NWNiZDEw
|
14
|
+
NDQ4OGJlZTA0MzNlNTdmNjRjMzc0YWZjODIxOWM5Y2VlMzA2NDhmMDczMjE1
|
15
|
+
NjJkZmQ1ZTU3Y2FlM2NmOGIzZGU4MWIwZWY3YmUyMjRjZWUyYjM=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Swagger::Blocks
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/fotinakis/swagger-blocks.svg?branch=master)](https://travis-ci.org/fotinakis/swagger-blocks)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/swagger-blocks.svg)](http://badge.fury.io/rb/swagger-blocks)
|
4
5
|
|
5
6
|
Swagger::Blocks is a DSL for pure Ruby code blocks that can be turned into JSON.
|
6
7
|
|
@@ -14,13 +15,19 @@ It helps you write API docs in the [Swagger](https://helloreverb.com/developers/
|
|
14
15
|
* Flexible—you can use Swagger::Blocks anywhere, split up blocks to fit your style preferences, etc. Since it's pure Ruby and serves definitions dynamically, you can easily use initializers/config objects to change values or even show/hide different APIs based on environment.
|
15
16
|
* 1:1 naming with the Swagger spec—block names and nesting should match almost exactly with the swagger spec, with rare exceptions to make things more convenient.
|
16
17
|
|
18
|
+
## Swagger UI demo
|
19
|
+
|
20
|
+
http://petstore.swagger.wordnik.com/#!/pet
|
21
|
+
|
22
|
+
![swagger-sample](https://cloud.githubusercontent.com/assets/75300/5822830/4769805c-a08c-11e4-9efe-d57cf0f752e0.png)
|
23
|
+
|
17
24
|
## Installation
|
18
25
|
|
19
26
|
Add this line to your application's Gemfile:
|
20
27
|
|
21
28
|
gem 'swagger-blocks'
|
22
29
|
|
23
|
-
Or install directly with `gem install swagger-blocks`.
|
30
|
+
Or install directly with `gem install swagger-blocks`.
|
24
31
|
|
25
32
|
## Example (Rails)
|
26
33
|
|
@@ -176,6 +183,11 @@ See the [swagger_blocks_spec.rb](https://github.com/fotinakis/swagger-blocks/blo
|
|
176
183
|
4. Push to the branch (`git push origin my-new-feature`)
|
177
184
|
5. Create a new Pull Request
|
178
185
|
|
186
|
+
## Release notes
|
187
|
+
|
188
|
+
* v1.0.1: Make backwards-compatible with Ruby 1.9.3.
|
189
|
+
* v1.0.0: Initial major release.
|
190
|
+
|
179
191
|
## Credits
|
180
192
|
|
181
193
|
Original idea inspired by **[@richhollis](https://github.com/richhollis/)**'s [swagger-docs](https://github.com/richhollis/swagger-docs/) gem.
|
data/lib/swagger/blocks.rb
CHANGED
@@ -13,12 +13,12 @@ module Swagger
|
|
13
13
|
base.extend(ClassMethods)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
def self.build_root_json(swaggered_classes)
|
17
17
|
data = Swagger::Blocks::InternalHelpers.parse_swaggered_classes(swaggered_classes)
|
18
18
|
data[:root_node].as_json
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
def self.build_api_json(resource_name, swaggered_classes)
|
22
22
|
data = Swagger::Blocks::InternalHelpers.parse_swaggered_classes(swaggered_classes)
|
23
23
|
api_node = data[:api_node_map][resource_name.to_sym]
|
24
24
|
raise Swagger::Blocks::NotFoundError.new(
|
@@ -26,9 +26,7 @@ module Swagger
|
|
26
26
|
|
27
27
|
# Aggregate all model definitions into a new ModelsNode tree and add it to the JSON.
|
28
28
|
temp_models_node = Swagger::Blocks::ModelsNode.call(name: 'models') { }
|
29
|
-
data[:models_nodes].each
|
30
|
-
temp_models_node.merge!(models_node)
|
31
|
-
end
|
29
|
+
data[:models_nodes].each { |models_node| temp_models_node.merge!(models_node) }
|
32
30
|
result = api_node.as_json
|
33
31
|
result.merge!(temp_models_node.as_json) if temp_models_node
|
34
32
|
result
|
@@ -130,10 +128,10 @@ module Swagger
|
|
130
128
|
class Node
|
131
129
|
attr_accessor :name
|
132
130
|
|
133
|
-
def self.call(
|
131
|
+
def self.call(options = {}, &block)
|
134
132
|
# Create a new instance and evaluate the block into it.
|
135
133
|
instance = new
|
136
|
-
instance.name = name if name
|
134
|
+
instance.name = options[:name] if options[:name]
|
137
135
|
instance.instance_eval(&block)
|
138
136
|
instance
|
139
137
|
end
|
data/swagger-blocks.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
|
-
spec.required_ruby_version = '>=
|
20
|
+
spec.required_ruby_version = '>= 1.9.3'
|
21
21
|
|
22
22
|
spec.add_development_dependency 'bundler'
|
23
23
|
spec.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger-blocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Fotinakis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: ''
|
@@ -73,9 +73,9 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .travis.yml
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE
|
81
81
|
- README.md
|
@@ -97,17 +97,17 @@ require_paths:
|
|
97
97
|
- lib
|
98
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- -
|
100
|
+
- - ! '>='
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: 1.9.3
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- -
|
105
|
+
- - ! '>='
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.4.5
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Define and serve live-updating Swagger JSON for Ruby apps.
|
@@ -116,4 +116,3 @@ test_files:
|
|
116
116
|
- spec/lib/swagger_blocks_spec.rb
|
117
117
|
- spec/lib/swagger_resource_listing.json
|
118
118
|
- spec/spec_helper.rb
|
119
|
-
has_rdoc:
|