skeleton 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/skeleton/config.rb +0 -1
- data/lib/skeleton/structure.rb +1 -0
- data/lib/skeleton/version.rb +1 -1
- data/spec/integrations/use_case_spec.rb +3 -2
- metadata +1 -2
- data/lib/skeleton/serializers/swagger.rb +0 -212
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58285e26920063075ffa03730ccae0341a4dc9d9
|
4
|
+
data.tar.gz: ad736281c2dbfe91f598f37ea9bc5eda9cd6cf4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58881cf63b7590a2e87d5bcfcd6f23efd55e62015e7bd8359bc96ae3c19b5fe84c20aa931370da7561e1befb8731bb0da2716939be02290ea358a04ecaed1683
|
7
|
+
data.tar.gz: 566f390c0c872baa4f54209c052321d901d19829733ce97cda6297704087094a7d55e6a22c34897fd42ff84918c2e001baaac946e5d84a26be336de5f8cf2ab0
|
data/lib/skeleton/config.rb
CHANGED
data/lib/skeleton/structure.rb
CHANGED
data/lib/skeleton/version.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'skeleton'
|
4
|
-
require 'skeleton/serializers/swagger'
|
5
|
-
require 'pp'
|
6
4
|
|
7
5
|
describe 'A simple use case' do
|
8
6
|
describe 'validating the first case' do
|
@@ -125,6 +123,9 @@ describe 'A simple use case' do
|
|
125
123
|
end
|
126
124
|
end
|
127
125
|
end
|
126
|
+
@structure.to_json
|
127
|
+
@structure.to_swagger_json
|
128
128
|
end
|
129
|
+
|
129
130
|
end
|
130
131
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skeleton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Johnston
|
@@ -103,7 +103,6 @@ files:
|
|
103
103
|
- lib/skeleton/security_definitions.rb
|
104
104
|
- lib/skeleton/security_requirement.rb
|
105
105
|
- lib/skeleton/security_scheme.rb
|
106
|
-
- lib/skeleton/serializers/swagger.rb
|
107
106
|
- lib/skeleton/structure.rb
|
108
107
|
- lib/skeleton/tag.rb
|
109
108
|
- lib/skeleton/version.rb
|
@@ -1,212 +0,0 @@
|
|
1
|
-
require 'multi_json'
|
2
|
-
|
3
|
-
module Skeleton
|
4
|
-
module Serializers
|
5
|
-
class Swagger
|
6
|
-
attr_accessor :structure
|
7
|
-
|
8
|
-
def initialize(args={})
|
9
|
-
@structure = args[:structure]
|
10
|
-
@version = args[:version] || '2.0'
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_hash
|
14
|
-
hash = {
|
15
|
-
swagger: @version,
|
16
|
-
info: dump_info_to_json(structure.info),
|
17
|
-
host: structure.host,
|
18
|
-
basePath: structure.base_path,
|
19
|
-
schemes: structure.schemes
|
20
|
-
}
|
21
|
-
|
22
|
-
hash[:consumes] = structure.consumes unless structure.consumes.empty?
|
23
|
-
hash[:produces] = structure.produces unless structure.produces.empty?
|
24
|
-
|
25
|
-
hash[:paths] = {}
|
26
|
-
structure.paths.each do |key, path|
|
27
|
-
hash[:paths][key] = dump_path_to_json(path)
|
28
|
-
end
|
29
|
-
|
30
|
-
hash
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_json
|
34
|
-
MultiJson.dump(to_hash)
|
35
|
-
end
|
36
|
-
|
37
|
-
def dump_info_to_json(info)
|
38
|
-
hash = {}
|
39
|
-
hash[:title] = info.title if info.title?
|
40
|
-
hash[:description] = info.description if info.description?
|
41
|
-
hash[:version] = info.version if info.version?
|
42
|
-
hash[:termsOfService] = info.terms_of_service if info.terms_of_service?
|
43
|
-
|
44
|
-
if info.license?
|
45
|
-
hash[:license] = {}
|
46
|
-
hash[:license][:name] = info.license.name if info.license.name?
|
47
|
-
hash[:license][:url] = info.license.url if info.license.url?
|
48
|
-
end
|
49
|
-
hash
|
50
|
-
end
|
51
|
-
|
52
|
-
def dump_path_to_json(path)
|
53
|
-
hash = {}
|
54
|
-
path.operations.each do |method, operation|
|
55
|
-
hash[method] = dump_operation_to_json(operation)
|
56
|
-
end
|
57
|
-
hash
|
58
|
-
end
|
59
|
-
|
60
|
-
def dump_operation_to_json(operation)
|
61
|
-
hash = {}
|
62
|
-
hash[:tags] = operation.tags if operation.tags?
|
63
|
-
hash[:summary] = operation.summary if operation.summary?
|
64
|
-
hash[:description] = operation.description if operation.description?
|
65
|
-
|
66
|
-
if operation.external_docs?
|
67
|
-
hash[:externalDocs] = dump_external_docs_to_json(operation.external_docs)
|
68
|
-
end
|
69
|
-
|
70
|
-
hash[:operationId] = operation.operation_id if operation.operation_id?
|
71
|
-
hash[:consumes] = operation.consumes if operation.consumes?
|
72
|
-
hash[:produces] = operation.produces if operation.produces?
|
73
|
-
|
74
|
-
if operation.parameters?
|
75
|
-
hash[:parameters] = operation.parameters.map do |parameter|
|
76
|
-
dump_parameter_to_json(parameter)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
hash[:responses] = dump_response_to_json(operation.responses) if operation.responses?
|
81
|
-
hash[:schemes] = operation.schemes if operation.schemes?
|
82
|
-
hash[:deprecated] = operation.deprecated if operation.deprecated?
|
83
|
-
|
84
|
-
if operation.security?
|
85
|
-
hash[:security] = dump_security_to_json(operation.security)
|
86
|
-
end
|
87
|
-
|
88
|
-
hash
|
89
|
-
end
|
90
|
-
|
91
|
-
def dump_parameter_to_json(parameter)
|
92
|
-
hash = {}
|
93
|
-
|
94
|
-
hash[:name] = parameter.name if parameter.name?
|
95
|
-
hash[:in] = parameter.location if parameter.location?
|
96
|
-
hash[:description] = parameter.description if parameter.description?
|
97
|
-
hash[:required] = parameter.required if parameter.required?
|
98
|
-
|
99
|
-
if parameter.schema?
|
100
|
-
hash[:schema] = dump_schema_to_json(parameter.schema)
|
101
|
-
else
|
102
|
-
hash[:type] = parameter.type if parameter.type?
|
103
|
-
hash[:format] = parameter.format if parameter.format?
|
104
|
-
hash[:items] = parameter.items if parameter.items?
|
105
|
-
hash[:collectionFormat] = parameter.collection_format if parameter.collection_format?
|
106
|
-
hash[:default] = parameter.default if parameter.default?
|
107
|
-
hash[:maximum] = parameter.maximum if parameter.maximum?
|
108
|
-
hash[:exclusiveMaximum] = parameter.exclusive_maximum if parameter.exclusive_maximum?
|
109
|
-
hash[:minimum] = parameter.minimum if parameter.minimum?
|
110
|
-
hash[:exclusiveMinimum] = parameter.exclusive_minimum if parameter.exclusive_minimum?
|
111
|
-
hash[:maxLength] = parameter.max_length if parameter.max_length?
|
112
|
-
hash[:minLength] = parameter.min_length if parameter.min_length?
|
113
|
-
hash[:pattern] = parameter.pattern if parameter.pattern?
|
114
|
-
hash[:maxItems] = parameter.max_items if parameter.max_items?
|
115
|
-
hash[:minItems] = parameter.min_items if parameter.min_items?
|
116
|
-
hash[:uniqueItems] = parameter.unique_items if parameter.unique_items?
|
117
|
-
hash[:enum] = parameter.enum if parameter.enum?
|
118
|
-
hash[:multipleOf] = parameter.multiple_of if parameter.multiple_of?
|
119
|
-
end
|
120
|
-
|
121
|
-
hash
|
122
|
-
end
|
123
|
-
|
124
|
-
def dump_external_docs_to_json(external_docs)
|
125
|
-
hash = {}
|
126
|
-
hash[:description] = external_docs.description if external_docs.description?
|
127
|
-
hash[:url] = external_docs.url if external_docs.url?
|
128
|
-
hash
|
129
|
-
end
|
130
|
-
|
131
|
-
def dump_security_to_json(security)
|
132
|
-
hash = {}
|
133
|
-
hash[:type] = security.type
|
134
|
-
hash[:description] = security.description
|
135
|
-
hash[:name] = security.name
|
136
|
-
hash[:in] = security.location
|
137
|
-
hash[:flow] = security.flow
|
138
|
-
hash[:authorizationUrl] = security.authorization_url
|
139
|
-
hash[:tokenUrl] = security.token_url
|
140
|
-
hash[:flow] = security.flow
|
141
|
-
hash[:scopes] = security.scopes
|
142
|
-
hash
|
143
|
-
end
|
144
|
-
|
145
|
-
def dump_response_to_json(response)
|
146
|
-
hash = {}
|
147
|
-
hash[:description] = response.description
|
148
|
-
hash[:schema] = dump_schema_to_json(response.schema) if response.schema?
|
149
|
-
hash[:headers] = dump_headers_to_json(response.headers) if response.headers?
|
150
|
-
hash[:examples] = dump_examples_to_json(response.examples) if response.examples?
|
151
|
-
hash
|
152
|
-
end
|
153
|
-
|
154
|
-
def dump_schema_to_json(schema)
|
155
|
-
hash = {}
|
156
|
-
hash[:discriminator] = schema.discriminator if schema.discriminator?
|
157
|
-
hash[:readOnly] = schema.read_only?
|
158
|
-
hash[:externalDocs] = schema.external_docs if schema.external_docs?
|
159
|
-
hash[:description] = schema.description if schema.description?
|
160
|
-
hash[:examples] = dump_examples_to_json(schema.examples) if schema.examples?
|
161
|
-
hash[:type] = schema.type if schema.type?
|
162
|
-
hash[:format] = schema.format if schema.format?
|
163
|
-
hash[:items] = schema.items if schema.items?
|
164
|
-
hash[:collectionFormat] = schema.collection_format if schema.collection_format?
|
165
|
-
hash[:default] = schema.default if schema.default?
|
166
|
-
hash[:maximum] = schema.maximum if schema.maximum?
|
167
|
-
hash[:exclusiveMaximum] = schema.exclusive_maximum if schema.exclusive_maximum?
|
168
|
-
hash[:minimum] = schema.minimum if schema.minimum?
|
169
|
-
hash[:exclusiveMinimum] = schema.exclusive_minimum if schema.exclusive_minimum?
|
170
|
-
hash[:maxLength] = schema.max_length if schema.max_length?
|
171
|
-
hash[:minLength] = schema.min_length if schema.min_length?
|
172
|
-
hash[:pattern] = schema.pattern if schema.pattern?
|
173
|
-
hash[:maxItems] = schema.max_items if schema.max_items?
|
174
|
-
hash[:minItems] = schema.min_items if schema.min_items?
|
175
|
-
hash[:uniqueItems] = schema.unique_items if schema.unique_items?
|
176
|
-
hash[:enum] = schema.enum if schema.enum?
|
177
|
-
hash[:multipleOf] = schema.multiple_of if schema.multiple_of?
|
178
|
-
hash
|
179
|
-
end
|
180
|
-
|
181
|
-
def dump_headers_to_json(header)
|
182
|
-
hash = {}
|
183
|
-
|
184
|
-
hash[:description] = header.description if header.description?
|
185
|
-
hash[:type] = header.type if header.type?
|
186
|
-
hash[:format] = header.format if header.format?
|
187
|
-
hash[:items] = header.items if header.items?
|
188
|
-
hash[:collectionFormat] = header.collection_format if header.collection_format?
|
189
|
-
hash[:default] = header.default if header.default?
|
190
|
-
hash[:maximum] = header.maximum if header.maximum?
|
191
|
-
hash[:exclusiveMaximum] = header.exclusive_maximum if header.exclusive_maximum?
|
192
|
-
hash[:minimum] = header.minimum if header.minimum?
|
193
|
-
hash[:exclusiveMinimum] = header.exclusive_minimum if header.exclusive_minimum?
|
194
|
-
hash[:maxLength] = header.max_length if header.max_length?
|
195
|
-
hash[:minLength] = header.min_length if header.min_length?
|
196
|
-
hash[:pattern] = header.pattern if header.pattern?
|
197
|
-
hash[:maxItems] = header.max_items if header.max_items?
|
198
|
-
hash[:minItems] = header.min_items if header.min_items?
|
199
|
-
hash[:uniqueItems] = header.unique_items if header.unique_items?
|
200
|
-
hash[:enum] = header.enum if header.enum?
|
201
|
-
hash[:multipleOf] = header.multiple_of if header.multiple_of?
|
202
|
-
|
203
|
-
hash
|
204
|
-
end
|
205
|
-
|
206
|
-
def dump_examples_to_json(schema)
|
207
|
-
hash = {}
|
208
|
-
hash
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|