raml-rb 1.0.0 → 1.1.0
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/.travis.yml +2 -1
- data/Gemfile +2 -0
- data/lib/raml/body.rb +1 -1
- data/lib/raml/parser/body.rb +1 -1
- data/lib/raml/parser/resource.rb +2 -0
- data/lib/raml/parser/root.rb +2 -3
- data/lib/raml/root.rb +3 -2
- data/lib/raml/version.rb +1 -1
- data/raml-rb.gemspec +1 -1
- data/spec/fixtures/all-the-things.raml +3 -0
- data/spec/fixtures/basic.raml +4 -2
- data/spec/fixtures/basic_raml_with_schemas.raml +50 -0
- data/spec/fixtures/basic_raml_with_types.raml +33 -0
- data/spec/lib/raml/parser/root_spec.rb +34 -1
- data/spec/lib/raml/root_spec.rb +7 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59af9e03788a3d397e64ae1975dbf11dd6d1e42a
|
4
|
+
data.tar.gz: 321d4c32b2e3c7d8bd5a811cdf210f09f35f36c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8afd602fbcf8746a9b6a4c1d45b82e69e684c89cc97d96f24582afb31815afa21cc7a6ae6e3c7bd9f3d4d70e419f58895f16243dc0b6bd435262049878db85eb
|
7
|
+
data.tar.gz: 2166e49473d3841821eff209b4cd0c34dd6f05e144cd4d6c8677c7813265b4e443f8a10bbb620c966479d7379fb25f65a57274454723554244b480021e495295
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/lib/raml/body.rb
CHANGED
data/lib/raml/parser/body.rb
CHANGED
data/lib/raml/parser/resource.rb
CHANGED
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 secured_by security_schemes]
|
12
|
+
BASIC_ATTRIBUTES = %w[title base_uri version base_uri_parameters media_type secured_by security_schemes types schemas]
|
13
13
|
|
14
14
|
attr_accessor :root, :traits, :resource_types, :attributes
|
15
15
|
|
@@ -49,7 +49,7 @@ module Raml
|
|
49
49
|
|
50
50
|
def parse_documentation(documentations)
|
51
51
|
documentations.each do |documentation_attributes|
|
52
|
-
root.
|
52
|
+
root.documentation << Raml::Parser::Documentation.new.parse(documentation_attributes)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -68,7 +68,6 @@ module Raml
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
72
71
|
end
|
73
72
|
end
|
74
73
|
end
|
data/lib/raml/root.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Raml
|
2
2
|
class Root
|
3
|
-
attr_accessor :title, :base_uri, :version, :resources, :documentation,
|
4
|
-
:base_uri_parameters, :media_type, :security_schemes, :secured_by
|
3
|
+
attr_accessor :title, :base_uri, :version, :resources, :documentation, :types,
|
4
|
+
:base_uri_parameters, :media_type, :security_schemes, :secured_by,
|
5
|
+
:schemas
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
@resources = []
|
data/lib/raml/version.rb
CHANGED
data/raml-rb.gemspec
CHANGED
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'rake', '~>10.3'
|
22
22
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
23
23
|
spec.add_development_dependency 'rspec-its', '~> 1.0'
|
24
|
-
spec.add_development_dependency 'coveralls',
|
24
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
25
25
|
end
|
data/spec/fixtures/basic.raml
CHANGED
@@ -24,17 +24,19 @@ traits:
|
|
24
24
|
pages:
|
25
25
|
description: The number of pages to return
|
26
26
|
type: number
|
27
|
-
- secured: !include http://raml-example.com/secured.yml
|
28
27
|
- notApplied:
|
29
28
|
fake: value
|
30
29
|
/songs:
|
31
|
-
is: [ paged
|
30
|
+
is: [ paged ]
|
32
31
|
get:
|
33
32
|
queryParameters:
|
34
33
|
genre:
|
35
34
|
description: filter the songs by genre
|
36
35
|
post:
|
37
36
|
/{songId}:
|
37
|
+
uriParameters:
|
38
|
+
songId:
|
39
|
+
type: integer
|
38
40
|
get:
|
39
41
|
responses:
|
40
42
|
200:
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#%RAML 0.8
|
2
|
+
---
|
3
|
+
title: e-BookMobile API
|
4
|
+
baseUri: http://api.e-bookmobile.com/{version}
|
5
|
+
version: 1.2
|
6
|
+
|
7
|
+
schemas:
|
8
|
+
Author: |
|
9
|
+
{
|
10
|
+
"$schema": "http://json-schema.org/schema",
|
11
|
+
"type": "object",
|
12
|
+
"description: "An author",
|
13
|
+
"properties": {
|
14
|
+
"id": { "type": "integer" },
|
15
|
+
"first_name": { "type": "string" },
|
16
|
+
"last_name": { "type": "string" },
|
17
|
+
"year_of_birth": {
|
18
|
+
"type": "integer",
|
19
|
+
"maxValue": 2017
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"required": [ "first_name", "last_name" ]
|
23
|
+
}
|
24
|
+
Authors: |
|
25
|
+
{
|
26
|
+
"$schema": "http://json-schema.org/schema",
|
27
|
+
"type": "array",
|
28
|
+
"description": "A list of authors",
|
29
|
+
"items": {
|
30
|
+
"type": "object",
|
31
|
+
"properties": {
|
32
|
+
"id": { "type": "integer" },
|
33
|
+
"first_name": { "type": "string" },
|
34
|
+
"last_name": { "type": "string" },
|
35
|
+
"year_of_birth": {
|
36
|
+
"type": "integer",
|
37
|
+
"maxValue": 2017
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
/authors:
|
44
|
+
post:
|
45
|
+
description: Add a new author to the system
|
46
|
+
responses:
|
47
|
+
204:
|
48
|
+
body:
|
49
|
+
application/json:
|
50
|
+
schema: Authors
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#%RAML 1.0
|
2
|
+
---
|
3
|
+
title: e-BookMobile API
|
4
|
+
baseUri: http://api.e-bookmobile.com/{version}
|
5
|
+
version: v1
|
6
|
+
|
7
|
+
types:
|
8
|
+
Author:
|
9
|
+
type: object
|
10
|
+
properties:
|
11
|
+
id: integer
|
12
|
+
first_name:
|
13
|
+
required: true
|
14
|
+
type: string
|
15
|
+
last_name:
|
16
|
+
required: true
|
17
|
+
type: string
|
18
|
+
year_of_birth:
|
19
|
+
required: false
|
20
|
+
type: integer
|
21
|
+
maximum: 2017
|
22
|
+
additionalProperties: false
|
23
|
+
Authors:
|
24
|
+
type: Author[]
|
25
|
+
|
26
|
+
/authors:
|
27
|
+
post:
|
28
|
+
description: Add a new author to the system
|
29
|
+
responses:
|
30
|
+
204:
|
31
|
+
body:
|
32
|
+
application/json:
|
33
|
+
type: Authors
|
@@ -38,6 +38,39 @@ describe Raml::Parser::Root do
|
|
38
38
|
its(:description) { should == 'filter the songs by genre' }
|
39
39
|
its(:type) { should == nil }
|
40
40
|
end
|
41
|
-
end
|
42
41
|
|
42
|
+
context 'using RAML types' do
|
43
|
+
let(:raml) { YAML.load File.read('spec/fixtures/basic_raml_with_types.raml') }
|
44
|
+
subject { Raml::Parser::Root.new.parse(raml) }
|
45
|
+
|
46
|
+
it { is_expected.to be_kind_of Raml::Root }
|
47
|
+
its(:base_uri) { should == 'http://api.e-bookmobile.com/{version}' }
|
48
|
+
its(:uri) { should == 'http://api.e-bookmobile.com/v1' }
|
49
|
+
its(:version) { should == 'v1' }
|
50
|
+
its(:media_type) { should be_nil }
|
51
|
+
its('resources.count') { should == 1 }
|
52
|
+
its('resources.first.http_methods.count') { should == 1 }
|
53
|
+
its('resources.first.http_methods.first.responses.count') { should == 1 }
|
54
|
+
its('resources.first.http_methods.first.query_parameters.count') { should == 0 }
|
55
|
+
its('documentation.count') { should == 0 }
|
56
|
+
its('resources.first.http_methods.first.responses.first.bodies.first.type') { should == 'Authors' }
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'using schemas' do
|
60
|
+
let(:raml) { YAML.load File.read('spec/fixtures/basic_raml_with_schemas.raml') }
|
61
|
+
subject { Raml::Parser::Root.new.parse(raml) }
|
62
|
+
|
63
|
+
it { is_expected.to be_kind_of Raml::Root }
|
64
|
+
its(:base_uri) { should == 'http://api.e-bookmobile.com/{version}' }
|
65
|
+
its(:uri) { should == 'http://api.e-bookmobile.com/1.2' }
|
66
|
+
its(:version) { should == 1.2 }
|
67
|
+
its(:media_type) { should be_nil }
|
68
|
+
its('resources.count') { should == 1 }
|
69
|
+
its('resources.first.http_methods.count') { should == 1 }
|
70
|
+
its('resources.first.http_methods.first.responses.count') { should == 1 }
|
71
|
+
its('resources.first.http_methods.first.query_parameters.count') { should == 0 }
|
72
|
+
its('documentation.count') { should == 0 }
|
73
|
+
its('resources.first.http_methods.first.responses.first.bodies.first.schema') { should == 'Authors' }
|
74
|
+
end
|
75
|
+
end
|
43
76
|
end
|
data/spec/lib/raml/root_spec.rb
CHANGED
@@ -26,6 +26,13 @@ describe Raml::Root do
|
|
26
26
|
it { is_expected.to eq('My RAML') }
|
27
27
|
end
|
28
28
|
|
29
|
+
describe '#types' do
|
30
|
+
let(:root) { Raml::Root.new }
|
31
|
+
before { root.types = { "Foo" => { "bar" => "baz" } } }
|
32
|
+
subject { root.types }
|
33
|
+
it { is_expected.to eq({ "Foo" => { "bar" => "baz" } }) }
|
34
|
+
end
|
35
|
+
|
29
36
|
describe '#version' do
|
30
37
|
let(:root) { Raml::Root.new }
|
31
38
|
before { root.version = '1.0' }
|
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: 1.
|
4
|
+
version: 1.1.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:
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,8 @@ files:
|
|
118
118
|
- raml-rb.gemspec
|
119
119
|
- spec/fixtures/all-the-things.raml
|
120
120
|
- spec/fixtures/basic.raml
|
121
|
+
- spec/fixtures/basic_raml_with_schemas.raml
|
122
|
+
- spec/fixtures/basic_raml_with_types.raml
|
121
123
|
- spec/lib/core_ext/hash_spec.rb
|
122
124
|
- spec/lib/raml/body_spec.rb
|
123
125
|
- spec/lib/raml/documentation_spec.rb
|
@@ -162,6 +164,8 @@ summary: A RAML parser implemented in Ruby
|
|
162
164
|
test_files:
|
163
165
|
- spec/fixtures/all-the-things.raml
|
164
166
|
- spec/fixtures/basic.raml
|
167
|
+
- spec/fixtures/basic_raml_with_schemas.raml
|
168
|
+
- spec/fixtures/basic_raml_with_types.raml
|
165
169
|
- spec/lib/core_ext/hash_spec.rb
|
166
170
|
- spec/lib/raml/body_spec.rb
|
167
171
|
- spec/lib/raml/documentation_spec.rb
|