skeleton 0.3.3 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +140 -65
- data/Rakefile +10 -3
- data/lib/skeleton.rb +6 -10
- data/lib/skeleton/contact.rb +1 -13
- data/lib/skeleton/error.rb +4 -0
- data/lib/skeleton/graph.rb +56 -0
- data/lib/skeleton/header.rb +2 -63
- data/lib/skeleton/items.rb +34 -0
- data/lib/skeleton/license.rb +1 -12
- data/lib/skeleton/model.rb +13 -17
- data/lib/skeleton/operation.rb +50 -121
- data/lib/skeleton/parameter.rb +31 -88
- data/lib/skeleton/parameters.rb +40 -0
- data/lib/skeleton/path.rb +42 -80
- data/lib/skeleton/presenter.rb +19 -0
- data/lib/skeleton/property.rb +6 -0
- data/lib/skeleton/response.rb +24 -45
- data/lib/skeleton/schema.rb +80 -63
- data/lib/skeleton/scope.rb +18 -0
- data/lib/skeleton/security_scheme.rb +19 -37
- data/lib/skeleton/serializers/options.rb +215 -0
- data/lib/skeleton/serializers/swagger.rb +197 -0
- data/lib/skeleton/structure.rb +92 -138
- data/lib/skeleton/swagger.rb +9 -0
- data/lib/skeleton/tag.rb +11 -16
- data/lib/skeleton/version.rb +1 -1
- data/skeleton.gemspec +2 -0
- data/test/fixtures/json-schema-draft-04.json +150 -0
- data/test/fixtures/schema.json +1482 -0
- data/test/integrations/validate_complex_schema_spec.rb +42 -0
- data/test/skeleton/graph_test.rb +22 -0
- data/test/skeleton/mapper_test.rb +84 -0
- data/test/skeleton/operation_test.rb +11 -0
- data/test/skeleton/parameter_test.rb +34 -0
- data/test/skeleton/parameters_test.rb +9 -0
- data/test/skeleton/path_test.rb +46 -0
- data/test/skeleton/property_test.rb +8 -0
- data/test/skeleton/serializers/options_test.rb +68 -0
- data/test/skeleton/serializers/swagger_test.rb +30 -0
- data/test/support/factories/structure_factory.rb +86 -0
- data/test/support/fixtures.rb +6 -0
- data/test/support/kissmetrics/core_api.rb +542 -0
- data/{spec/spec_helper.rb → test/test_helper.rb} +7 -1
- metadata +73 -25
- data/lib/skeleton/config.rb +0 -37
- data/lib/skeleton/documentation.rb +0 -17
- data/lib/skeleton/example.rb +0 -31
- data/lib/skeleton/headers.rb +0 -50
- data/lib/skeleton/helpers/controller_helpers.rb +0 -25
- data/lib/skeleton/info.rb +0 -40
- data/lib/skeleton/item.rb +0 -99
- data/lib/skeleton/responses.rb +0 -59
- data/lib/skeleton/scopes.rb +0 -24
- data/lib/skeleton/security_definitions.rb +0 -46
- data/lib/skeleton/security_requirement.rb +0 -29
- data/spec/integrations/use_case_spec.rb +0 -131
- data/spec/skeleton/operation_spec.rb +0 -113
- data/spec/skeleton/serializers/contact_spec.rb +0 -30
- data/spec/skeleton/serializers/documentation_spec.rb +0 -23
- data/spec/skeleton/serializers/header_spec.rb +0 -57
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
|
-
|
3
|
+
require 'pp'
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require 'minitest/spec'
|
6
6
|
require 'minitest/pride'
|
7
7
|
|
8
|
+
require 'webmock/minitest'
|
9
|
+
|
8
10
|
module Minitest
|
9
11
|
class Spec
|
10
12
|
class << self
|
@@ -12,3 +14,7 @@ module Minitest
|
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
17
|
+
|
18
|
+
require_relative 'support/fixtures'
|
19
|
+
require_relative 'support/kissmetrics/core_api'
|
20
|
+
require_relative 'support/factories/structure_factory'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skeleton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Johnston
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json-schema
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
description: Construct an api skeleton for options
|
70
98
|
email:
|
71
99
|
- warmwaffles@gmail.com
|
@@ -82,37 +110,46 @@ files:
|
|
82
110
|
- Rakefile
|
83
111
|
- lib/skeleton.rb
|
84
112
|
- lib/skeleton/attributes.rb
|
85
|
-
- lib/skeleton/config.rb
|
86
113
|
- lib/skeleton/contact.rb
|
87
|
-
- lib/skeleton/
|
88
|
-
- lib/skeleton/
|
114
|
+
- lib/skeleton/error.rb
|
115
|
+
- lib/skeleton/graph.rb
|
89
116
|
- lib/skeleton/header.rb
|
90
|
-
- lib/skeleton/
|
91
|
-
- lib/skeleton/helpers/controller_helpers.rb
|
92
|
-
- lib/skeleton/info.rb
|
93
|
-
- lib/skeleton/item.rb
|
117
|
+
- lib/skeleton/items.rb
|
94
118
|
- lib/skeleton/license.rb
|
95
119
|
- lib/skeleton/model.rb
|
96
120
|
- lib/skeleton/operation.rb
|
97
121
|
- lib/skeleton/parameter.rb
|
122
|
+
- lib/skeleton/parameters.rb
|
98
123
|
- lib/skeleton/path.rb
|
124
|
+
- lib/skeleton/presenter.rb
|
125
|
+
- lib/skeleton/property.rb
|
99
126
|
- lib/skeleton/response.rb
|
100
|
-
- lib/skeleton/responses.rb
|
101
127
|
- lib/skeleton/schema.rb
|
102
|
-
- lib/skeleton/
|
103
|
-
- lib/skeleton/security_definitions.rb
|
104
|
-
- lib/skeleton/security_requirement.rb
|
128
|
+
- lib/skeleton/scope.rb
|
105
129
|
- lib/skeleton/security_scheme.rb
|
130
|
+
- lib/skeleton/serializers/options.rb
|
131
|
+
- lib/skeleton/serializers/swagger.rb
|
106
132
|
- lib/skeleton/structure.rb
|
133
|
+
- lib/skeleton/swagger.rb
|
107
134
|
- lib/skeleton/tag.rb
|
108
135
|
- lib/skeleton/version.rb
|
109
136
|
- skeleton.gemspec
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
137
|
+
- test/fixtures/json-schema-draft-04.json
|
138
|
+
- test/fixtures/schema.json
|
139
|
+
- test/integrations/validate_complex_schema_spec.rb
|
140
|
+
- test/skeleton/graph_test.rb
|
141
|
+
- test/skeleton/mapper_test.rb
|
142
|
+
- test/skeleton/operation_test.rb
|
143
|
+
- test/skeleton/parameter_test.rb
|
144
|
+
- test/skeleton/parameters_test.rb
|
145
|
+
- test/skeleton/path_test.rb
|
146
|
+
- test/skeleton/property_test.rb
|
147
|
+
- test/skeleton/serializers/options_test.rb
|
148
|
+
- test/skeleton/serializers/swagger_test.rb
|
149
|
+
- test/support/factories/structure_factory.rb
|
150
|
+
- test/support/fixtures.rb
|
151
|
+
- test/support/kissmetrics/core_api.rb
|
152
|
+
- test/test_helper.rb
|
116
153
|
homepage: https://github.com/warmwaffles/skeleton
|
117
154
|
licenses:
|
118
155
|
- MIT
|
@@ -138,9 +175,20 @@ signing_key:
|
|
138
175
|
specification_version: 4
|
139
176
|
summary: Construct an api skeleton for options
|
140
177
|
test_files:
|
141
|
-
-
|
142
|
-
-
|
143
|
-
-
|
144
|
-
-
|
145
|
-
-
|
146
|
-
-
|
178
|
+
- test/fixtures/json-schema-draft-04.json
|
179
|
+
- test/fixtures/schema.json
|
180
|
+
- test/integrations/validate_complex_schema_spec.rb
|
181
|
+
- test/skeleton/graph_test.rb
|
182
|
+
- test/skeleton/mapper_test.rb
|
183
|
+
- test/skeleton/operation_test.rb
|
184
|
+
- test/skeleton/parameter_test.rb
|
185
|
+
- test/skeleton/parameters_test.rb
|
186
|
+
- test/skeleton/path_test.rb
|
187
|
+
- test/skeleton/property_test.rb
|
188
|
+
- test/skeleton/serializers/options_test.rb
|
189
|
+
- test/skeleton/serializers/swagger_test.rb
|
190
|
+
- test/support/factories/structure_factory.rb
|
191
|
+
- test/support/fixtures.rb
|
192
|
+
- test/support/kissmetrics/core_api.rb
|
193
|
+
- test/test_helper.rb
|
194
|
+
has_rdoc:
|
data/lib/skeleton/config.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'skeleton/structure'
|
2
|
-
|
3
|
-
module Skeleton
|
4
|
-
class Config
|
5
|
-
def structure
|
6
|
-
@structure ||= Skeleton::Structure.new
|
7
|
-
end
|
8
|
-
|
9
|
-
def info(&block)
|
10
|
-
yield(structure.info) if block
|
11
|
-
end
|
12
|
-
|
13
|
-
def define(&block)
|
14
|
-
yield(structure) if block
|
15
|
-
end
|
16
|
-
|
17
|
-
def contact(&block)
|
18
|
-
yield(structure.info.contact) if block
|
19
|
-
end
|
20
|
-
|
21
|
-
def license(&block)
|
22
|
-
yield(structure.info.license) if block
|
23
|
-
end
|
24
|
-
|
25
|
-
def path(resource, &block)
|
26
|
-
structure.path(resource, &block)
|
27
|
-
end
|
28
|
-
|
29
|
-
def parameter(location, name, &block)
|
30
|
-
structure.parameter(location, name, &block)
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_swagger_json
|
34
|
-
structure.to_swagger_json
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'skeleton/model'
|
2
|
-
|
3
|
-
module Skeleton
|
4
|
-
class Documentation < Model
|
5
|
-
|
6
|
-
attr_accessor :description, :url
|
7
|
-
attr_presence :description, :url
|
8
|
-
|
9
|
-
def to_h
|
10
|
-
hash = {}
|
11
|
-
hash[:description] = description if description?
|
12
|
-
hash[:url] = url if url?
|
13
|
-
hash
|
14
|
-
end
|
15
|
-
alias_method :to_swagger_hash, :to_h
|
16
|
-
end
|
17
|
-
end
|
data/lib/skeleton/example.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Skeleton
|
2
|
-
class Example
|
3
|
-
def initialize
|
4
|
-
@mimes = {}
|
5
|
-
end
|
6
|
-
|
7
|
-
def []=(mime_type, value)
|
8
|
-
@mimes[mime_type] = value
|
9
|
-
end
|
10
|
-
|
11
|
-
def [](mime_type)
|
12
|
-
@mimes[mime_type]
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_h
|
16
|
-
hash = {}
|
17
|
-
@mimes.each do |type, value|
|
18
|
-
hash[type] = value.respond_to?(:to_h) ? value.to_h : value
|
19
|
-
end
|
20
|
-
hash
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_swagger_hash
|
24
|
-
hash = {}
|
25
|
-
@mimes.each do |type, value|
|
26
|
-
hash[type] = value.respond_to?(:to_h) ? value.to_swagger_hash : value
|
27
|
-
end
|
28
|
-
hash
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/skeleton/headers.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'skeleton/model'
|
2
|
-
require 'skeleton/header'
|
3
|
-
|
4
|
-
module Skeleton
|
5
|
-
class Headers < Model
|
6
|
-
def initialize(args={})
|
7
|
-
@fields = {}
|
8
|
-
args.each { |k, v| set(k, v)}
|
9
|
-
end
|
10
|
-
|
11
|
-
def get(name)
|
12
|
-
@fields[name]
|
13
|
-
end
|
14
|
-
alias_method :[], :get
|
15
|
-
|
16
|
-
def set(name, value)
|
17
|
-
case value
|
18
|
-
when Hash
|
19
|
-
@fields[name] = Skeleton::Header.new(value)
|
20
|
-
else
|
21
|
-
@fields[name] = value
|
22
|
-
end
|
23
|
-
end
|
24
|
-
alias_method :[]=, :set
|
25
|
-
|
26
|
-
def to_h
|
27
|
-
hash ={}
|
28
|
-
@fields.each do |name, value|
|
29
|
-
if value.respond_to?(:to_h)
|
30
|
-
hash[name] = value.to_h
|
31
|
-
else
|
32
|
-
hash[name] = value
|
33
|
-
end
|
34
|
-
end
|
35
|
-
hash
|
36
|
-
end
|
37
|
-
|
38
|
-
def to_swagger_hash
|
39
|
-
hash ={}
|
40
|
-
@fields.each do |name, value|
|
41
|
-
if value.respond_to?(:to_swagger_hash)
|
42
|
-
hash[name] = value.to_swagger_hash
|
43
|
-
else
|
44
|
-
hash[name] = value
|
45
|
-
end
|
46
|
-
end
|
47
|
-
hash
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'skeleton/structure'
|
2
|
-
|
3
|
-
module Skeleton
|
4
|
-
module Helpers
|
5
|
-
module ControllerHelpers
|
6
|
-
def self.included(base)
|
7
|
-
base.send(:extend, ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def define_api_path(resource, &block)
|
12
|
-
Skeleton.config.path(resource, &block)
|
13
|
-
end
|
14
|
-
|
15
|
-
def define_global_parameter(location, name, &block)
|
16
|
-
Skeleton.config.parameter(location, name, &block)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def get_api_path(resource)
|
21
|
-
Skeleton.config.path(resource)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/skeleton/info.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'skeleton/model'
|
2
|
-
require 'skeleton/license'
|
3
|
-
require 'skeleton/contact'
|
4
|
-
|
5
|
-
module Skeleton
|
6
|
-
class Info < Model
|
7
|
-
attr_accessor :title, :description, :terms_of_service, :license, :version
|
8
|
-
attr_presence :title, :description, :terms_of_service, :license, :version
|
9
|
-
|
10
|
-
def contact
|
11
|
-
@contact ||= Skeleton::Contact.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def license
|
15
|
-
@license ||= Skeleton::License.new
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_h
|
19
|
-
hash = {}
|
20
|
-
hash[:title] = title if title?
|
21
|
-
hash[:description] = description if description?
|
22
|
-
hash[:version] = version if version?
|
23
|
-
hash[:terms_of_service] = terms_of_service if terms_of_service?
|
24
|
-
hash[:license] = license.to_h
|
25
|
-
hash[:contact] = contact.to_h
|
26
|
-
hash
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_swagger_hash
|
30
|
-
hash = {}
|
31
|
-
hash[:title] = title if title?
|
32
|
-
hash[:description] = description if description?
|
33
|
-
hash[:version] = version if version?
|
34
|
-
hash[:termsOfService] = terms_of_service if terms_of_service?
|
35
|
-
hash[:license] = license.to_swagger_hash
|
36
|
-
hash[:contact] = contact.to_swagger_hash
|
37
|
-
hash
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/lib/skeleton/item.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'skeleton/model'
|
2
|
-
|
3
|
-
module Skeleton
|
4
|
-
class Item < Model
|
5
|
-
attr_accessor :type, :format, :title, :description, :default, :multiple_of,
|
6
|
-
:maximum, :exclusive_maximum, :minimum, :exclusive_minimum,
|
7
|
-
:max_length, :min_length, :pattern, :max_items, :min_items,
|
8
|
-
:unique_items, :max_properties, :min_properties, :items
|
9
|
-
|
10
|
-
attr_writer :enum
|
11
|
-
attr_presence :exclusive_maximum, :exclusive_minimum, :unique_items, :items
|
12
|
-
|
13
|
-
def enum
|
14
|
-
@enum ||= []
|
15
|
-
end
|
16
|
-
|
17
|
-
def enum?
|
18
|
-
!enum.empty?
|
19
|
-
end
|
20
|
-
|
21
|
-
def array?
|
22
|
-
@type == 'array'
|
23
|
-
end
|
24
|
-
|
25
|
-
def string?
|
26
|
-
@type == 'string'
|
27
|
-
end
|
28
|
-
|
29
|
-
def number?
|
30
|
-
@type == 'number'
|
31
|
-
end
|
32
|
-
|
33
|
-
def integer?
|
34
|
-
@type == 'integer'
|
35
|
-
end
|
36
|
-
|
37
|
-
def boolean?
|
38
|
-
@type == 'boolean'
|
39
|
-
end
|
40
|
-
|
41
|
-
def file?
|
42
|
-
@type == 'file'
|
43
|
-
end
|
44
|
-
|
45
|
-
def to_h
|
46
|
-
hash = {}
|
47
|
-
hash[:type] = type if type?
|
48
|
-
hash[:format] = format if format?
|
49
|
-
|
50
|
-
hash[:items] = items.to_hash if items?
|
51
|
-
|
52
|
-
hash[:title] = title if title?
|
53
|
-
hash[:description] = description if description?
|
54
|
-
hash[:default] = default if default?
|
55
|
-
hash[:multiple_of] = multiple_of if multiple_of?
|
56
|
-
hash[:maximum] = maximum if maximum?
|
57
|
-
hash[:exclusive_maximum] = exclusive_maximum if exclusive_maximum?
|
58
|
-
hash[:minimum] = minimum if minimum?
|
59
|
-
hash[:exclusive_minimum] = exclusive_minimum if exclusive_minimum?
|
60
|
-
hash[:max_length] = max_length if max_length?
|
61
|
-
hash[:min_length] = min_length if min_length?
|
62
|
-
hash[:pattern] = pattern if pattern?
|
63
|
-
hash[:max_items] = max_items if max_items?
|
64
|
-
hash[:min_items] = min_items if min_items?
|
65
|
-
hash[:unique_items] = unique_items if unique_items?
|
66
|
-
hash[:max_properties] = max_properties if max_properties?
|
67
|
-
hash[:min_properties] = min_properties if min_properties?
|
68
|
-
hash[:enum] = enum if enum?
|
69
|
-
hash
|
70
|
-
end
|
71
|
-
|
72
|
-
def to_swagger_hash
|
73
|
-
hash = {}
|
74
|
-
hash[:type] = type if type?
|
75
|
-
hash[:format] = format if format?
|
76
|
-
|
77
|
-
hash[:items] = items.to_swagger_hash if items?
|
78
|
-
|
79
|
-
hash[:title] = title if title?
|
80
|
-
hash[:description] = description if description?
|
81
|
-
hash[:default] = default if default?
|
82
|
-
hash[:multipleOf] = multiple_of if multiple_of?
|
83
|
-
hash[:maximum] = maximum if maximum?
|
84
|
-
hash[:exclusiveMaximum] = exclusive_maximum if exclusive_maximum?
|
85
|
-
hash[:minimum] = minimum if minimum?
|
86
|
-
hash[:exclusiveMinimum] = exclusive_minimum if exclusive_minimum?
|
87
|
-
hash[:maxLength] = max_length if max_length?
|
88
|
-
hash[:minLength] = min_length if min_length?
|
89
|
-
hash[:pattern] = pattern if pattern?
|
90
|
-
hash[:maxItems] = max_items if max_items?
|
91
|
-
hash[:minItems] = min_items if min_items?
|
92
|
-
hash[:uniqueItems] = unique_items if unique_items?
|
93
|
-
hash[:maxProperties] = max_properties if max_properties?
|
94
|
-
hash[:minProperties] = min_properties if min_properties?
|
95
|
-
hash[:enum] = enum if enum?
|
96
|
-
hash
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|