raml-rb 0.0.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/raml/parser/resource.rb +3 -3
- data/lib/raml/parser/root.rb +1 -1
- data/lib/raml/resource.rb +5 -5
- data/lib/raml/root.rb +1 -1
- data/lib/raml/version.rb +1 -1
- data/spec/fixtures/all-the-things.raml +10 -0
- data/spec/fixtures/basic.raml +10 -0
- data/spec/lib/raml/parser/root_spec.rb +7 -6
- data/spec/lib/raml/resource_spec.rb +1 -1
- data/spec/lib/raml/root_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df2e4d4523124e124d26a17682ad25e97bafeb1f
|
4
|
+
data.tar.gz: 57fecb9fa9a2195963b4918381da41699cb4ccaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2138442d6609232fa226ec002f5143a404ab3c023252eeec71dbc6e58e9695f2bd848577a90362b42e3dbeebbb92b7c578e6d5c694812f00a4ef67edee2bc2b
|
7
|
+
data.tar.gz: 958813a38ecd31dad8d8c6dd588dfa1af9b907d9504346d693769d953cbe6edcf8b02fefa98759b4d2a9ec10efaa8760ddfafee223ff7dbea57d89690c030d78
|
data/lib/raml/parser/resource.rb
CHANGED
@@ -11,7 +11,7 @@ module Raml
|
|
11
11
|
extend Forwardable
|
12
12
|
include Raml::Parser::Util
|
13
13
|
|
14
|
-
|
14
|
+
HTTP_METHODS = %w[get put post delete]
|
15
15
|
|
16
16
|
attr_accessor :parent_node, :resource, :trait_names, :attributes
|
17
17
|
def_delegators :@parent, :traits, :resource_types
|
@@ -37,8 +37,8 @@ module Raml
|
|
37
37
|
case key
|
38
38
|
when /^\//
|
39
39
|
resource.resources << Raml::Parser::Resource.new(self).parse(resource, key, value)
|
40
|
-
when *
|
41
|
-
resource.
|
40
|
+
when *HTTP_METHODS
|
41
|
+
resource.http_methods << Raml::Parser::Method.new(self).parse(key, value)
|
42
42
|
when 'is'
|
43
43
|
@trait_names = value
|
44
44
|
else
|
data/lib/raml/parser/root.rb
CHANGED
@@ -9,7 +9,7 @@ module Raml
|
|
9
9
|
class Root
|
10
10
|
include Raml::Parser::Util
|
11
11
|
|
12
|
-
BASIC_ATTRIBUTES = %w[title base_uri version base_uri_parameters media_type]
|
12
|
+
BASIC_ATTRIBUTES = %w[title base_uri version base_uri_parameters media_type secured_by security_schemes]
|
13
13
|
|
14
14
|
attr_accessor :root, :traits, :resource_types, :attributes
|
15
15
|
|
data/lib/raml/resource.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Raml
|
2
2
|
class Resource
|
3
|
-
attr_accessor :parent, :
|
3
|
+
attr_accessor :parent, :http_methods, :uri_partial, :resources
|
4
4
|
|
5
5
|
def initialize(parent, uri_partial)
|
6
|
-
@parent
|
7
|
-
@uri_partial
|
8
|
-
@
|
9
|
-
@resources
|
6
|
+
@parent = parent
|
7
|
+
@uri_partial = uri_partial
|
8
|
+
@http_methods = []
|
9
|
+
@resources = []
|
10
10
|
end
|
11
11
|
|
12
12
|
def path
|
data/lib/raml/root.rb
CHANGED
data/lib/raml/version.rb
CHANGED
@@ -12,6 +12,16 @@ documentation:
|
|
12
12
|
- title: RAML Baml
|
13
13
|
content: |
|
14
14
|
- Project: [source code](https://github.com/jpb/raml-rb)
|
15
|
+
securedBy: [ authenticationHeader ]
|
16
|
+
securitySchemes:
|
17
|
+
- authenticationHeader:
|
18
|
+
describedBy:
|
19
|
+
headers:
|
20
|
+
Authorization:
|
21
|
+
type: string
|
22
|
+
responses:
|
23
|
+
401:
|
24
|
+
description: Authentication required
|
15
25
|
traits:
|
16
26
|
- paged:
|
17
27
|
queryParameters:
|
data/spec/fixtures/basic.raml
CHANGED
@@ -8,6 +8,16 @@ baseUriParameters:
|
|
8
8
|
type: String
|
9
9
|
version: v1
|
10
10
|
mediaType: application/json
|
11
|
+
securedBy: [ authenticationHeader ]
|
12
|
+
securitySchemes:
|
13
|
+
- authenticationHeader:
|
14
|
+
describedBy:
|
15
|
+
headers:
|
16
|
+
Authorization:
|
17
|
+
type: string
|
18
|
+
responses:
|
19
|
+
401:
|
20
|
+
description: Authentication required
|
11
21
|
traits:
|
12
22
|
- paged:
|
13
23
|
queryParameters:
|
@@ -15,24 +15,25 @@ describe Raml::Parser::Root do
|
|
15
15
|
should == {"environment" => { "description"=>"The deployed environment", "type"=>"String" }}
|
16
16
|
end
|
17
17
|
its(:media_type) { should == "application/json" }
|
18
|
+
its(:secured_by) { should == [ "authenticationHeader" ] }
|
18
19
|
its('resources.count') { should == 1 }
|
19
|
-
its('resources.first.
|
20
|
-
its('resources.first.
|
21
|
-
its('resources.first.
|
20
|
+
its('resources.first.http_methods.count') { should == 2 }
|
21
|
+
its('resources.first.http_methods.first.responses.count') { should == 0 }
|
22
|
+
its('resources.first.http_methods.first.query_parameters.count') { should == 2 }
|
22
23
|
its('documentation.count') { should == 0 }
|
23
|
-
its('resources.first.resources.first.
|
24
|
+
its('resources.first.resources.first.http_methods.first.responses.first.bodies.first.example') do
|
24
25
|
should include '{"artist":"Pink Floyd", "title":"Wish You Were Here"}'
|
25
26
|
end
|
26
27
|
|
27
28
|
context 'trait-inherited attributes' do
|
28
|
-
subject { Raml::Parser::Root.new.parse(raml).resources.first.
|
29
|
+
subject { Raml::Parser::Root.new.parse(raml).resources.first.http_methods.first.query_parameters.first }
|
29
30
|
its(:name) { should == 'pages' }
|
30
31
|
its(:description) { should == 'The number of pages to return' }
|
31
32
|
its(:type) { should == 'number' }
|
32
33
|
end
|
33
34
|
|
34
35
|
context 'non trait-inherited attributes' do
|
35
|
-
subject { Raml::Parser::Root.new.parse(raml).resources.first.
|
36
|
+
subject { Raml::Parser::Root.new.parse(raml).resources.first.http_methods.first.query_parameters.last }
|
36
37
|
its(:name) { should == 'genre' }
|
37
38
|
its(:description) { should == 'filter the songs by genre' }
|
38
39
|
its(:type) { should == nil }
|
data/spec/lib/raml/root_spec.rb
CHANGED
@@ -40,6 +40,20 @@ describe Raml::Root do
|
|
40
40
|
it { is_expected.to eq('') }
|
41
41
|
end
|
42
42
|
|
43
|
+
describe '#security_schemes' do
|
44
|
+
let(:root) { Raml::Root.new }
|
45
|
+
before { root.security_schemes = 'foo' }
|
46
|
+
subject { root.security_schemes }
|
47
|
+
it { is_expected.to eq('foo') }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#secured_by' do
|
51
|
+
let(:root) { Raml::Root.new }
|
52
|
+
before { root.secured_by = [ 'oauth_2_0' ] }
|
53
|
+
subject { root.secured_by }
|
54
|
+
it { is_expected.to eq([ 'oauth_2_0' ]) }
|
55
|
+
end
|
56
|
+
|
43
57
|
describe '#media_type' do
|
44
58
|
let(:root) { Raml::Root.new }
|
45
59
|
before { root.media_type = 'application/json' }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raml-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Brennan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|