raml_parser 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -2
- data/lib/raml_parser.rb +40 -32
- data/lib/raml_parser/model.rb +7 -4
- data/lib/raml_parser/version.rb +1 -1
- data/lib/raml_parser/yaml_helper.rb +5 -5
- data/spec/examples/raml/protocols1.raml +14 -0
- data/spec/examples/raml/protocols2.raml +15 -0
- data/spec/examples/raml/protocols3.raml +16 -0
- data/spec/examples/raml/required.raml +24 -0
- data/spec/lib/raml_parser/{yaml_parser_spec.rb → yaml_helper_spec.rb} +3 -3
- data/spec/lib/raml_parser_spec.rb +34 -0
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c566421a59a1d92ee889714c3c84f37e6c1673d0
|
4
|
+
data.tar.gz: 0a572f77481d481ccba55d87eb09f34962e34abd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3520c84d38f67cfca3073be3c03ece838c40a54bb07b592e62b2e16a0a722b1fbb008195689c3b4202d22b839318bce7429f144b949d9edb8e18c89ad723e50
|
7
|
+
data.tar.gz: 52a5b63afb2a9c76702d13326a063e76af27481241d833e2085bb365c0892dd7faa586c4d47347e26266432407f962e1866e803bece269f11598ce3e0497080f
|
data/README.md
CHANGED
@@ -16,20 +16,43 @@ source 'https://rubygems.org'
|
|
16
16
|
gem 'raml_parser'
|
17
17
|
```
|
18
18
|
|
19
|
+
or for bleeding edge:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'raml_parser', :git => 'https://github.com/ePages-de/raml_parser.git', :branch => 'develop'
|
23
|
+
```
|
24
|
+
|
19
25
|
And then execute:
|
20
26
|
|
21
27
|
$ bundle
|
22
28
|
|
23
29
|
## Usage
|
24
30
|
|
25
|
-
|
31
|
+
```ruby
|
32
|
+
require 'raml_parser'
|
33
|
+
|
34
|
+
raml = RamlParser::Parser.parse_file('path/to/api.raml')
|
35
|
+
|
36
|
+
# generate some markdown out of it
|
37
|
+
for res in raml.resources
|
38
|
+
puts '# Resource ' + res.absolute_uri + "\n\n"
|
39
|
+
for name, meth in res.methods
|
40
|
+
puts '## Method ' + meth.method + "\n\n"
|
41
|
+
unless meth.description.nil?
|
42
|
+
puts meth.description + "\n\n"
|
43
|
+
else
|
44
|
+
puts "(TODO)\n\n"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
```
|
26
49
|
|
27
50
|
## What parts of RAML are not supported
|
28
51
|
|
29
52
|
These are features of the RAML 0.8 specification that are not fully handled yet. This list should be complete, i.e. everything not listed here should work.
|
30
53
|
|
31
|
-
* [Protocols](http://raml.org/spec.html#protocols)
|
32
54
|
* [Named parameters with multiple types](http://raml.org/spec.html#named-parameters-with-multiple-types)
|
55
|
+
* [Optional properties in resource types](http://raml.org/spec.html#optional-properties)
|
33
56
|
|
34
57
|
## Contributing
|
35
58
|
|
data/lib/raml_parser.rb
CHANGED
@@ -31,15 +31,19 @@ module RamlParser
|
|
31
31
|
root.version = node.hash('version').value
|
32
32
|
root.base_uri = node.hash('baseUri').or_default('').value.gsub('{version}', root.version || '')
|
33
33
|
root.media_type = node.hash('mediaType').value
|
34
|
-
root.secured_by = node.hash('securedBy').or_default([]).
|
35
|
-
root.documentation = node.hash('documentation').
|
36
|
-
root.schemas = node.hash('schemas').
|
37
|
-
root.security_schemes = node.hash('securitySchemes').
|
38
|
-
root.resource_types = node.hash('resourceTypes').mark_all(:used).
|
39
|
-
root.traits = node.hash('traits').mark_all(:used).
|
40
|
-
|
41
|
-
|
42
|
-
|
34
|
+
root.secured_by = node.hash('securedBy').or_default([]).array_values { |n| n.value }
|
35
|
+
root.documentation = node.hash('documentation').array_values { |n| parse_documenation(n) }
|
36
|
+
root.schemas = node.hash('schemas').arrayhash_values { |n| n.value }
|
37
|
+
root.security_schemes = node.hash('securitySchemes').arrayhash_values { |n| parse_security_scheme(n) }
|
38
|
+
root.resource_types = node.hash('resourceTypes').mark_all(:used).arrayhash_values { |n| n }
|
39
|
+
root.traits = node.hash('traits').mark_all(:used).arrayhash_values { |n| n }
|
40
|
+
|
41
|
+
implicit_protocols = (root.base_uri.scan(/^(http|https):\/\//).first || []).map { |p| p.upcase }
|
42
|
+
explicit_protocols = node.hash('protocols').array_values { |n| n.value }
|
43
|
+
root.protocols = explicit_protocols.empty? ? implicit_protocols : explicit_protocols
|
44
|
+
|
45
|
+
implicit_base_uri_parameters = extract_uri_parameters(root.base_uri, true)
|
46
|
+
explicit_base_uri_parameters = node.hash('baseUriParameters').hash_values { |n| parse_named_parameter(n, true) }
|
43
47
|
root.base_uri_parameters = implicit_base_uri_parameters.merge(explicit_base_uri_parameters)
|
44
48
|
|
45
49
|
root.resources = traverse_resources(node, nil) do |n,parent|
|
@@ -52,26 +56,26 @@ module RamlParser
|
|
52
56
|
root
|
53
57
|
end
|
54
58
|
|
55
|
-
def self.parse_resource(node, root, parent_absolute_uri, parent_relative_uri, parent_uri_parameters,
|
59
|
+
def self.parse_resource(node, root, parent_absolute_uri, parent_relative_uri, parent_uri_parameters, as_partial)
|
56
60
|
node = node.or_default({})
|
57
61
|
resource = Model::Resource.new(parent_absolute_uri + node.key, parent_relative_uri + node.key)
|
58
62
|
resource.display_name = node.hash('displayName').value
|
59
63
|
resource.description = node.hash('description').value
|
60
64
|
resource.type = parse_type(node.hash('type'))
|
61
65
|
resource.is = parse_is(node.hash('is'))
|
62
|
-
resource.secured_by = (root.secured_by + node.hash('securedBy').or_default([]).
|
63
|
-
resource.methods = Hash[find_method_nodes(node).map { |n| [n.key, parse_method(n, root, resource,
|
66
|
+
resource.secured_by = (root.secured_by + node.hash('securedBy').or_default([]).array_values { |n| n.value }).uniq
|
67
|
+
resource.methods = Hash[find_method_nodes(node).map { |n| [n.key, parse_method(n, root, resource, as_partial)] }]
|
64
68
|
|
65
69
|
root_base_uri_parameters = root.base_uri_parameters
|
66
|
-
own_base_uri_parameters = node.hash('baseUriParameters').
|
70
|
+
own_base_uri_parameters = node.hash('baseUriParameters').hash_values { |n| parse_named_parameter(n, true) }
|
67
71
|
resource.base_uri_parameters = root_base_uri_parameters.merge(own_base_uri_parameters)
|
68
72
|
|
69
|
-
implicit_uri_parameters = extract_uri_parameters(node.key)
|
70
|
-
explicit_uri_parameters = node.hash('uriParameters').
|
71
|
-
raise 'Can only explicitly specify URI parameters from the current relative URI' unless
|
73
|
+
implicit_uri_parameters = extract_uri_parameters(node.key, true)
|
74
|
+
explicit_uri_parameters = node.hash('uriParameters').hash_values { |n| parse_named_parameter(n, true) }
|
75
|
+
raise 'Can only explicitly specify URI parameters from the current relative URI' unless as_partial or (explicit_uri_parameters.keys - implicit_uri_parameters.keys).empty?
|
72
76
|
resource.uri_parameters = parent_uri_parameters.merge(implicit_uri_parameters).merge(explicit_uri_parameters)
|
73
77
|
|
74
|
-
unless
|
78
|
+
unless as_partial
|
75
79
|
resource = mixin_resource_types(node, root, resource)
|
76
80
|
resource.display_name = resource.relative_uri unless resource.display_name
|
77
81
|
end
|
@@ -79,18 +83,22 @@ module RamlParser
|
|
79
83
|
resource
|
80
84
|
end
|
81
85
|
|
82
|
-
def self.parse_method(node, root, resource,
|
86
|
+
def self.parse_method(node, root, resource, as_partial)
|
83
87
|
node = node.or_default({})
|
84
88
|
method = Model::Method.new(node.key.upcase)
|
85
89
|
method.description = node.hash('description').value
|
86
|
-
method.query_parameters = node.hash('queryParameters').
|
87
|
-
method.bodies = node.hash('body').
|
88
|
-
method.responses = node.hash('responses').
|
89
|
-
method.headers = node.hash('headers').
|
90
|
-
method.secured_by = (resource.secured_by + node.hash('securedBy').or_default([]).
|
90
|
+
method.query_parameters = node.hash('queryParameters').hash_values { |n| parse_named_parameter(n, false) }
|
91
|
+
method.bodies = node.hash('body').hash_values { |n| parse_body(n, root) }
|
92
|
+
method.responses = node.hash('responses').hash_values { |n| parse_response(n, root) }
|
93
|
+
method.headers = node.hash('headers').hash_values { |n| parse_named_parameter(n, false) }
|
94
|
+
method.secured_by = (resource.secured_by + node.hash('securedBy').or_default([]).array_values { |n| n.value }).uniq if resource
|
91
95
|
method.is = parse_is(node.hash('is'))
|
92
96
|
|
93
|
-
|
97
|
+
root_protocols = as_partial ? [] : root.protocols
|
98
|
+
explicit_protocols = node.hash('protocols').array_values { |n| n.value }
|
99
|
+
method.protocols = explicit_protocols.empty? ? root_protocols : explicit_protocols
|
100
|
+
|
101
|
+
unless as_partial
|
94
102
|
method = mixin_traits(node, root, method, resource)
|
95
103
|
end
|
96
104
|
|
@@ -102,12 +110,12 @@ module RamlParser
|
|
102
110
|
response = Model::Response.new(node.key)
|
103
111
|
response.display_name = node.hash('displayName').value
|
104
112
|
response.description = node.hash('description').value
|
105
|
-
response.bodies = node.hash('body').
|
106
|
-
response.headers = node.hash('headers').
|
113
|
+
response.bodies = node.hash('body').hash_values { |n| parse_body(n, root) }
|
114
|
+
response.headers = node.hash('headers').hash_values { |n| parse_named_parameter(n, false) }
|
107
115
|
response
|
108
116
|
end
|
109
117
|
|
110
|
-
def self.parse_named_parameter(node)
|
118
|
+
def self.parse_named_parameter(node, required_per_default)
|
111
119
|
if node.value.is_a? Array
|
112
120
|
node.mark_all(:unsupported)
|
113
121
|
# TODO: Not yet supported named parameters with multiple types
|
@@ -119,7 +127,7 @@ module RamlParser
|
|
119
127
|
named_parameter.type = node.hash('type').or_default('string').value
|
120
128
|
named_parameter.display_name = node.hash('displayName').or_default(named_parameter.name).value
|
121
129
|
named_parameter.description = node.hash('description').value
|
122
|
-
named_parameter.required = node.hash('required').or_default(
|
130
|
+
named_parameter.required = node.hash('required').or_default(required_per_default).value
|
123
131
|
named_parameter.default = node.hash('default').value
|
124
132
|
named_parameter.example = node.hash('example').value
|
125
133
|
named_parameter.min_length = node.hash('minLength').value
|
@@ -127,7 +135,7 @@ module RamlParser
|
|
127
135
|
named_parameter.minimum = node.hash('minimum').value
|
128
136
|
named_parameter.maximum = node.hash('maximum').value
|
129
137
|
named_parameter.repeat = node.hash('repeat').value
|
130
|
-
named_parameter.enum = node.hash('enum').or_default([]).
|
138
|
+
named_parameter.enum = node.hash('enum').or_default([]).array_values { |n| n.value }
|
131
139
|
named_parameter.pattern = node.hash('pattern').value
|
132
140
|
named_parameter
|
133
141
|
end
|
@@ -138,7 +146,7 @@ module RamlParser
|
|
138
146
|
body.example = node.hash('example').value
|
139
147
|
body.schema = node.hash('schema').value
|
140
148
|
body.schema = root.schemas[body.schema] if root.schemas.has_key? body.schema
|
141
|
-
body.form_parameters = node.hash('formParameters').
|
149
|
+
body.form_parameters = node.hash('formParameters').hash_values { |n| parse_named_parameter(n, false) }
|
142
150
|
# TODO: Form parameters are only allowed for media type application/x-www-form-urlencoded or multipart/form-data
|
143
151
|
body
|
144
152
|
end
|
@@ -273,9 +281,9 @@ module RamlParser
|
|
273
281
|
(node.value || {}).select { |k,_| is_method(k) }.map { |k,_| node.hash(k) }
|
274
282
|
end
|
275
283
|
|
276
|
-
def self.extract_uri_parameters(uri)
|
284
|
+
def self.extract_uri_parameters(uri, required_per_default)
|
277
285
|
names = uri.scan(/\{([a-zA-Z\_\-]+)\}/).map { |m| m.first }
|
278
|
-
Hash[names.map { |name| [name, Model::NamedParameter.new(name, 'string', name)] }]
|
286
|
+
Hash[names.map { |name| [name, Model::NamedParameter.new(name, 'string', name, nil, required_per_default)] }]
|
279
287
|
end
|
280
288
|
|
281
289
|
def self.traverse_resources(node, parent_resource, &code)
|
data/lib/raml_parser/model.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module RamlParser
|
2
2
|
module Model
|
3
3
|
class Root
|
4
|
-
attr_accessor :title, :base_uri, :version, :media_type, :schemas, :security_schemes, :base_uri_parameters, :resource_types, :traits, :secured_by, :documentation, :resources
|
4
|
+
attr_accessor :title, :base_uri, :version, :media_type, :schemas, :security_schemes, :base_uri_parameters, :resource_types, :traits, :protocols, :secured_by, :documentation, :resources
|
5
5
|
|
6
|
-
def initialize(title = nil, base_uri = nil, version = nil, media_type = nil, schemas = {}, security_schemes = {}, base_uri_parameters = {}, resource_types = {}, traits = {}, secured_by = [], documentation = [], resources = [])
|
6
|
+
def initialize(title = nil, base_uri = nil, version = nil, media_type = nil, schemas = {}, security_schemes = {}, base_uri_parameters = {}, resource_types = {}, traits = {}, protocols = [], secured_by = [], documentation = [], resources = [])
|
7
7
|
@title = title
|
8
8
|
@base_uri = base_uri
|
9
9
|
@version = version
|
@@ -13,6 +13,7 @@ module RamlParser
|
|
13
13
|
@base_uri_parameters = base_uri_parameters
|
14
14
|
@resource_types = resource_types
|
15
15
|
@traits = traits
|
16
|
+
@protocols = protocols
|
16
17
|
@secured_by = secured_by
|
17
18
|
@documentation = documentation
|
18
19
|
@resources = resources
|
@@ -52,9 +53,9 @@ module RamlParser
|
|
52
53
|
end
|
53
54
|
|
54
55
|
class Method
|
55
|
-
attr_accessor :method, :description, :query_parameters, :responses, :bodies, :headers, :is, :secured_by
|
56
|
+
attr_accessor :method, :description, :query_parameters, :responses, :bodies, :headers, :is, :protocols, :secured_by
|
56
57
|
|
57
|
-
def initialize(method, description = nil, query_parameters = {}, responses = {}, bodies = {}, headers = {}, is = {}, secured_by = [])
|
58
|
+
def initialize(method, description = nil, query_parameters = {}, responses = {}, bodies = {}, headers = {}, is = {}, protocols = [], secured_by = [])
|
58
59
|
@method = method
|
59
60
|
@description = description
|
60
61
|
@query_parameters = query_parameters
|
@@ -62,6 +63,7 @@ module RamlParser
|
|
62
63
|
@bodies = bodies
|
63
64
|
@headers = headers
|
64
65
|
@is = is
|
66
|
+
@protocols = protocols
|
65
67
|
@secured_by = secured_by
|
66
68
|
end
|
67
69
|
|
@@ -74,6 +76,7 @@ module RamlParser
|
|
74
76
|
method.bodies = a.bodies.merge(b.bodies)
|
75
77
|
method.headers = a.headers.merge(b.headers)
|
76
78
|
method.is = a.is.merge(b.is)
|
79
|
+
method.protocols = (a.protocols + b.protocols).uniq
|
77
80
|
method.secured_by = (a.secured_by + b.secured_by).uniq
|
78
81
|
|
79
82
|
method
|
data/lib/raml_parser/version.rb
CHANGED
@@ -37,9 +37,9 @@ module RamlParser
|
|
37
37
|
def mark_all(what)
|
38
38
|
mark(what)
|
39
39
|
if @value.is_a? Hash
|
40
|
-
|
40
|
+
hash_values { |n| n.mark_all(what) }
|
41
41
|
elsif @value.is_a? Array
|
42
|
-
|
42
|
+
array_values { |n| n.mark_all(what) }
|
43
43
|
end
|
44
44
|
self
|
45
45
|
end
|
@@ -54,7 +54,7 @@ module RamlParser
|
|
54
54
|
new_node
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
57
|
+
def array_values(&code)
|
58
58
|
(@value || []).each_with_index.map { |_,i| code.call(array(i)) }
|
59
59
|
end
|
60
60
|
|
@@ -64,7 +64,7 @@ module RamlParser
|
|
64
64
|
new_node
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def hash_values(&code)
|
68
68
|
Hash[(@value || {}).map { |k,v| [k, code.call(hash(k))] }]
|
69
69
|
end
|
70
70
|
|
@@ -76,7 +76,7 @@ module RamlParser
|
|
76
76
|
new_node2
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
79
|
+
def arrayhash_values(&code)
|
80
80
|
Hash[(@value || []).each_with_index.map { |_,i|
|
81
81
|
node = arrayhash(i)
|
82
82
|
[node.key, code.call(node)]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#%RAML 0.8
|
2
|
+
---
|
3
|
+
title: Example API
|
4
|
+
baseUri: http://localhost:3000
|
5
|
+
/a/{b}:
|
6
|
+
/c/{d}:
|
7
|
+
uriParameters:
|
8
|
+
d:
|
9
|
+
/e/{f}:
|
10
|
+
uriParameters:
|
11
|
+
f:
|
12
|
+
required: false
|
13
|
+
/g/{h}:
|
14
|
+
uriParameters:
|
15
|
+
h:
|
16
|
+
required: true
|
17
|
+
/i:
|
18
|
+
get:
|
19
|
+
queryParameters:
|
20
|
+
j:
|
21
|
+
k:
|
22
|
+
required: false
|
23
|
+
l:
|
24
|
+
required: true
|
@@ -18,14 +18,14 @@ RSpec.describe RamlParser::YamlNode do
|
|
18
18
|
yml = RamlParser::YamlHelper.read_yaml('spec/examples/yaml/traversing.yml')
|
19
19
|
root = RamlParser::YamlNode.new(nil, 'root', yml)
|
20
20
|
expect(root.hash('array').array(0).value).to eq 'foo'
|
21
|
-
expect(root.hash('array').
|
21
|
+
expect(root.hash('array').array_values { |n| n.key }).to eq ['[0]', '[1]']
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'has a working hash/hash_map method' do
|
25
25
|
yml = RamlParser::YamlHelper.read_yaml('spec/examples/yaml/traversing.yml')
|
26
26
|
root = RamlParser::YamlNode.new(nil, 'root', yml)
|
27
27
|
expect(root.hash('integer').value).to eq 10
|
28
|
-
expect(root.
|
28
|
+
expect(root.hash_values { |n| 0 }).to eq ({'string'=>0, 'integer'=>0, 'hash'=>0, 'array'=>0, 'array_complex'=>0})
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'has a working arrayhash/arrayhash_map method' do
|
@@ -33,6 +33,6 @@ RSpec.describe RamlParser::YamlNode do
|
|
33
33
|
root = RamlParser::YamlNode.new(nil, 'root', yml)
|
34
34
|
expect(root.hash('array_complex').arrayhash(0).key).to eq 'foo'
|
35
35
|
expect(root.hash('array_complex').arrayhash(0).value).to eq nil
|
36
|
-
expect(root.hash('array_complex').
|
36
|
+
expect(root.hash('array_complex').arrayhash_values { |n| n.value }).to eq ({'foo'=>nil, 'bar'=>{'sub'=>'element'}})
|
37
37
|
end
|
38
38
|
end
|
@@ -125,6 +125,29 @@ RSpec.describe RamlParser::Parser do
|
|
125
125
|
expect(raml2.resources[2].base_uri_parameters['user'].description).to eq 'Changed'
|
126
126
|
end
|
127
127
|
|
128
|
+
it 'parses protocols' do
|
129
|
+
raml1 = RamlParser::Parser.parse_file('spec/examples/raml/protocols1.raml')
|
130
|
+
expect(raml1.protocols).to eq []
|
131
|
+
expect(raml1.resources[0].methods['get'].protocols).to eq %w()
|
132
|
+
expect(raml1.resources[1].methods['get'].protocols).to eq %w(HTTP HTTPS)
|
133
|
+
expect(raml1.resources[2].methods['get'].protocols).to eq %w(HTTP)
|
134
|
+
expect(raml1.resources[3].methods['get'].protocols).to eq %w(HTTPS)
|
135
|
+
|
136
|
+
raml2 = RamlParser::Parser.parse_file('spec/examples/raml/protocols2.raml')
|
137
|
+
expect(raml2.protocols).to eq ['HTTP']
|
138
|
+
expect(raml2.resources[0].methods['get'].protocols).to eq %w(HTTP)
|
139
|
+
expect(raml2.resources[1].methods['get'].protocols).to eq %w(HTTP HTTPS)
|
140
|
+
expect(raml2.resources[2].methods['get'].protocols).to eq %w(HTTP)
|
141
|
+
expect(raml2.resources[3].methods['get'].protocols).to eq %w(HTTPS)
|
142
|
+
|
143
|
+
raml3 = RamlParser::Parser.parse_file('spec/examples/raml/protocols3.raml')
|
144
|
+
expect(raml3.protocols).to eq ['HTTP', 'HTTPS']
|
145
|
+
expect(raml3.resources[0].methods['get'].protocols).to eq %w(HTTP HTTPS)
|
146
|
+
expect(raml3.resources[1].methods['get'].protocols).to eq %w(HTTP HTTPS)
|
147
|
+
expect(raml3.resources[2].methods['get'].protocols).to eq %w(HTTP)
|
148
|
+
expect(raml3.resources[3].methods['get'].protocols).to eq %w(HTTPS)
|
149
|
+
end
|
150
|
+
|
128
151
|
it 'handle secured by' do
|
129
152
|
raml1 = RamlParser::Parser.parse_file('spec/examples/raml/securedby1.raml')
|
130
153
|
expect(raml1.resources[0].methods['get'].secured_by).to eq ['oauth_1_0']
|
@@ -175,6 +198,17 @@ RSpec.describe RamlParser::Parser do
|
|
175
198
|
expect(raml4.resources[0].methods['get'].responses[200].headers['X-Foobar-Pong'].display_name).to eq 'PingPong'
|
176
199
|
end
|
177
200
|
|
201
|
+
it 'properly sets required property' do
|
202
|
+
raml = RamlParser::Parser.parse_file('spec/examples/raml/required.raml')
|
203
|
+
expect(raml.resources[0].uri_parameters['b'].required).to eq true
|
204
|
+
expect(raml.resources[1].uri_parameters['d'].required).to eq true
|
205
|
+
expect(raml.resources[2].uri_parameters['f'].required).to eq false
|
206
|
+
expect(raml.resources[3].uri_parameters['h'].required).to eq true
|
207
|
+
expect(raml.resources[4].methods['get'].query_parameters['j'].required).to eq false
|
208
|
+
expect(raml.resources[4].methods['get'].query_parameters['k'].required).to eq false
|
209
|
+
expect(raml.resources[4].methods['get'].query_parameters['l'].required).to eq true
|
210
|
+
end
|
211
|
+
|
178
212
|
it 'fixed issue #2' do
|
179
213
|
raml = RamlParser::Parser.parse_file('spec/examples/raml/issue2.raml')
|
180
214
|
expect(raml.resources[0].methods.keys).to eq ['post', 'get']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raml_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Hoffmeister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -127,8 +127,12 @@ files:
|
|
127
127
|
- spec/examples/raml/methods.raml
|
128
128
|
- spec/examples/raml/parameters.raml
|
129
129
|
- spec/examples/raml/parametersinflection.raml
|
130
|
+
- spec/examples/raml/protocols1.raml
|
131
|
+
- spec/examples/raml/protocols2.raml
|
132
|
+
- spec/examples/raml/protocols3.raml
|
130
133
|
- spec/examples/raml/queryparameters.raml
|
131
134
|
- spec/examples/raml/requestbodies.raml
|
135
|
+
- spec/examples/raml/required.raml
|
132
136
|
- spec/examples/raml/resources.raml
|
133
137
|
- spec/examples/raml/resourcetypes.raml
|
134
138
|
- spec/examples/raml/responses.raml
|
@@ -144,7 +148,7 @@ files:
|
|
144
148
|
- spec/examples/yaml/include2.yml
|
145
149
|
- spec/examples/yaml/simple.yml
|
146
150
|
- spec/examples/yaml/traversing.yml
|
147
|
-
- spec/lib/raml_parser/
|
151
|
+
- spec/lib/raml_parser/yaml_helper_spec.rb
|
148
152
|
- spec/lib/raml_parser_spec.rb
|
149
153
|
- spec/spec_helper.rb
|
150
154
|
homepage: https://github.com/ePages-de/raml_parser
|
@@ -214,8 +218,12 @@ test_files:
|
|
214
218
|
- spec/examples/raml/methods.raml
|
215
219
|
- spec/examples/raml/parameters.raml
|
216
220
|
- spec/examples/raml/parametersinflection.raml
|
221
|
+
- spec/examples/raml/protocols1.raml
|
222
|
+
- spec/examples/raml/protocols2.raml
|
223
|
+
- spec/examples/raml/protocols3.raml
|
217
224
|
- spec/examples/raml/queryparameters.raml
|
218
225
|
- spec/examples/raml/requestbodies.raml
|
226
|
+
- spec/examples/raml/required.raml
|
219
227
|
- spec/examples/raml/resources.raml
|
220
228
|
- spec/examples/raml/resourcetypes.raml
|
221
229
|
- spec/examples/raml/responses.raml
|
@@ -231,6 +239,6 @@ test_files:
|
|
231
239
|
- spec/examples/yaml/include2.yml
|
232
240
|
- spec/examples/yaml/simple.yml
|
233
241
|
- spec/examples/yaml/traversing.yml
|
234
|
-
- spec/lib/raml_parser/
|
242
|
+
- spec/lib/raml_parser/yaml_helper_spec.rb
|
235
243
|
- spec/lib/raml_parser_spec.rb
|
236
244
|
- spec/spec_helper.rb
|