raml-rb 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df2e4d4523124e124d26a17682ad25e97bafeb1f
4
- data.tar.gz: 57fecb9fa9a2195963b4918381da41699cb4ccaf
3
+ metadata.gz: 59af9e03788a3d397e64ae1975dbf11dd6d1e42a
4
+ data.tar.gz: 321d4c32b2e3c7d8bd5a811cdf210f09f35f36c3
5
5
  SHA512:
6
- metadata.gz: b2138442d6609232fa226ec002f5143a404ab3c023252eeec71dbc6e58e9695f2bd848577a90362b42e3dbeebbb92b7c578e6d5c694812f00a4ef67edee2bc2b
7
- data.tar.gz: 958813a38ecd31dad8d8c6dd588dfa1af9b907d9504346d693769d953cbe6edcf8b02fefa98759b4d2a9ec10efaa8760ddfafee223ff7dbea57d89690c030d78
6
+ metadata.gz: 8afd602fbcf8746a9b6a4c1d45b82e69e684c89cc97d96f24582afb31815afa21cc7a6ae6e3c7bd9f3d4d70e419f58895f16243dc0b6bd435262049878db85eb
7
+ data.tar.gz: 2166e49473d3841821eff209b4cd0c34dd6f05e144cd4d6c8677c7813265b4e443f8a10bbb620c966479d7379fb25f65a57274454723554244b480021e495295
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ .byebug_history
@@ -4,7 +4,8 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.8
6
6
  - 2.2.0
7
- - 2.3.0
7
+ - 2.3.3
8
+ - 2.4.0
8
9
  branches:
9
10
  only:
10
11
  - master
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in raml-rb.gemspec
4
4
  gemspec
5
+
6
+ gem "byebug"
@@ -1,6 +1,6 @@
1
1
  module Raml
2
2
  class Body
3
- attr_accessor :content_type, :schema, :example
3
+ attr_accessor :content_type, :schema, :example, :type
4
4
 
5
5
  def initialize(content_type)
6
6
  @content_type = content_type
@@ -7,7 +7,7 @@ module Raml
7
7
  class Body
8
8
  include Raml::Parser::Util
9
9
 
10
- BASIC_ATTRIBUTES = %w[schema example]
10
+ BASIC_ATTRIBUTES = %w[schema example type]
11
11
 
12
12
  attr_accessor :body, :attributes
13
13
 
@@ -41,6 +41,8 @@ module Raml
41
41
  resource.http_methods << Raml::Parser::Method.new(self).parse(key, value)
42
42
  when 'is'
43
43
  @trait_names = value
44
+ when 'uri_parameters'
45
+ @uri_parameters = value
44
46
  else
45
47
  raise UnknownAttributeError.new "Unknown resource key: #{key}"
46
48
  end
@@ -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.documentations << Raml::Parser::Documentation.new.parse(documentation_attributes)
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
@@ -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 = []
@@ -1,3 +1,3 @@
1
1
  module Raml
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -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', '~> 0.8'
24
+ spec.add_development_dependency 'coveralls', '~> 0.8'
25
25
  end
@@ -37,6 +37,9 @@ traits:
37
37
  description: filter the songs by genre
38
38
  post:
39
39
  /{songId}:
40
+ uriParameters:
41
+ songId:
42
+ type: integer
40
43
  get:
41
44
  responses:
42
45
  200:
@@ -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, secured ]
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
@@ -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.0.0
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: 2016-06-29 00:00:00.000000000 Z
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