raml_parser 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abe1cc6ee7e11604113e202e4c9b301b96bdcbe5
4
- data.tar.gz: 98af92840d95058855e4bfe9f599886fffafe2a3
3
+ metadata.gz: ff9e7a1f4e30b306aef82ac79df6419da2965b39
4
+ data.tar.gz: fbb5b40f82f8da01c76006b19eda007632caee27
5
5
  SHA512:
6
- metadata.gz: f47f74ef12621fe8156078eb71df570f89390e379ec2d46682b5406a3bee6ef872810a03c5105c6b795fe2618fdd12df781f540c18105f1af046293456553050
7
- data.tar.gz: 97557ac026a4dc26aaab273e4d9556f30b6e8255d0c92061aa1ac7895c83739a2d32930f4b9da581d30d4ef698341f67bf0771a177f9add568b577bf2760e54c
6
+ metadata.gz: 41753e3578d079704dd08fa98049ffe5a78aef722e159f89006c262f2a757e6637f56568ac78dd87585e4ed21236c48c8adfd8f8dfffb64b696da7700af3f74d
7
+ data.tar.gz: 785ad520d0b6f48509e693fad7a60ee5241f01cf9524104de759bdc2107daba4b30b4753545081cb2ab3ddc1fdd948df09b0ce0a6f42ba1b4267c796f26a30e6
data/lib/raml_parser.rb CHANGED
@@ -82,7 +82,6 @@ module RamlParser
82
82
  def self.parse_method(node, root, resource, as_trait)
83
83
  node = node.or_default({})
84
84
  method = Model::Method.new(node.key.upcase)
85
- method.display_name = node.hash('displayName').value
86
85
  method.description = node.hash('description').value
87
86
  method.query_parameters = node.hash('queryParameters').hash_map { |n| parse_named_parameter(n) }
88
87
  method.bodies = node.hash('body').hash_map { |n| parse_body(n, root) }
@@ -93,7 +92,6 @@ module RamlParser
93
92
 
94
93
  unless as_trait
95
94
  method = mixin_traits(node, root, method, resource)
96
- method.display_name = method.method + ' ' + resource.relative_uri unless method.display_name
97
95
  end
98
96
 
99
97
  method
@@ -52,11 +52,10 @@ module RamlParser
52
52
  end
53
53
 
54
54
  class Method
55
- attr_accessor :method, :display_name, :description, :query_parameters, :responses, :bodies, :headers, :is, :secured_by
55
+ attr_accessor :method, :description, :query_parameters, :responses, :bodies, :headers, :is, :secured_by
56
56
 
57
- def initialize(method, display_name = nil, description = nil, query_parameters = {}, responses = {}, bodies = {}, headers = {}, is = {}, secured_by = [])
57
+ def initialize(method, description = nil, query_parameters = {}, responses = {}, bodies = {}, headers = {}, is = {}, secured_by = [])
58
58
  @method = method
59
- @display_name = display_name
60
59
  @description = description
61
60
  @query_parameters = query_parameters
62
61
  @responses = responses
@@ -69,7 +68,6 @@ module RamlParser
69
68
  def self.merge(a, b)
70
69
  method = Method.new(b.method)
71
70
 
72
- method.display_name = if b.display_name then b.display_name else a.display_name end
73
71
  method.description = if b.description then b.description else a.description end
74
72
  method.query_parameters = a.query_parameters.merge(b.query_parameters)
75
73
  method.responses = a.responses.merge(b.responses)
@@ -1,3 +1,3 @@
1
1
  module RamlParser
2
- VERSION = "0.2"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -6,4 +6,4 @@ baseUri: http://localhost:3000
6
6
  get:
7
7
  /b:
8
8
  get:
9
- displayName: This is /a/b
9
+ description: This is /a/b
@@ -4,7 +4,6 @@ title: Example API
4
4
  baseUri: http://localhost:3000
5
5
  traits:
6
6
  - searchable:
7
- displayName: Foo
8
7
  description: This is searchable
9
8
  queryParameters:
10
9
  q:
@@ -19,7 +18,6 @@ traits:
19
18
  /b:
20
19
  get:
21
20
  is: [ searchable, sortable ]
22
- displayName: /a/b
23
21
  description: This is resource /a/b
24
22
  queryParameters:
25
23
  sort:
@@ -48,9 +48,7 @@ RSpec.describe RamlParser::Parser do
48
48
  it 'parses methods' do
49
49
  raml = RamlParser::Parser.parse_file('spec/examples/raml/methods.raml')
50
50
  expect(raml.resources[0].methods['get'].method).to eq 'GET'
51
- expect(raml.resources[0].methods['get'].display_name).to eq 'GET /a'
52
51
  expect(raml.resources[1].methods['get'].method).to eq 'GET'
53
- expect(raml.resources[1].methods['get'].display_name).to eq 'This is /a/b'
54
52
  end
55
53
 
56
54
  it 'parses responses' do
@@ -144,10 +142,8 @@ RSpec.describe RamlParser::Parser do
144
142
  it 'mixes in traits' do
145
143
  raml = RamlParser::Parser.parse_file('spec/examples/raml/traits.raml')
146
144
  expect(raml.resources[0].methods['get'].query_parameters.map { |name,_| name }).to eq ['q', 'key', 'order']
147
- expect(raml.resources[0].methods['get'].display_name).to eq 'Foo'
148
145
  expect(raml.resources[0].methods['get'].description).to eq 'This is sortable'
149
146
  expect(raml.resources[1].methods['get'].query_parameters.map { |name,_| name }).to eq ['q', 'key', 'order', 'sort']
150
- expect(raml.resources[1].methods['get'].display_name).to eq '/a/b'
151
147
  expect(raml.resources[1].methods['get'].description).to eq 'This is resource /a/b'
152
148
  expect(raml.resources[2].methods['get'].query_parameters.map { |name,_| name }).to eq ['key', 'order']
153
149
  expect(raml.resources[3].methods['get'].query_parameters.map { |name,_| name }).to eq ['key', 'order', 'q']
@@ -174,13 +170,9 @@ RSpec.describe RamlParser::Parser do
174
170
  expect(raml3.resources[0].methods['get'].query_parameters['q1'].display_name).to eq 'q1'
175
171
  expect(raml3.resources[1].methods['get'].query_parameters['q2'].display_name).to eq 'This is the second query parameter'
176
172
 
177
- raml4 = RamlParser::Parser.parse_file('spec/examples/raml/methods.raml')
178
- expect(raml4.resources[0].methods['get'].display_name).to eq 'GET /a'
179
- expect(raml4.resources[1].methods['get'].display_name).to eq 'This is /a/b'
180
-
181
- raml5 = RamlParser::Parser.parse_file('spec/examples/raml/headers.raml')
182
- expect(raml5.resources[0].methods['get'].headers['X-Foobar-Ping'].display_name).to eq 'X-Foobar-Ping'
183
- expect(raml5.resources[0].methods['get'].responses[200].headers['X-Foobar-Pong'].display_name).to eq 'PingPong'
173
+ raml4 = RamlParser::Parser.parse_file('spec/examples/raml/headers.raml')
174
+ expect(raml4.resources[0].methods['get'].headers['X-Foobar-Ping'].display_name).to eq 'X-Foobar-Ping'
175
+ expect(raml4.resources[0].methods['get'].responses[200].headers['X-Foobar-Pong'].display_name).to eq 'PingPong'
184
176
  end
185
177
 
186
178
  it 'fixed issue #2' do
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.1
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-02-16 00:00:00.000000000 Z
11
+ date: 2015-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,7 +77,6 @@ files:
77
77
  - .rspec
78
78
  - .travis.yml
79
79
  - Gemfile
80
- - Gemfile.lock
81
80
  - LICENSE.txt
82
81
  - README.md
83
82
  - Rakefile