raml_parser 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +39 -0
  8. data/Rakefile +7 -0
  9. data/lib/raml_parser.rb +270 -0
  10. data/lib/raml_parser/model.rb +146 -0
  11. data/lib/raml_parser/version.rb +3 -0
  12. data/lib/raml_parser/yaml_helper.rb +122 -0
  13. data/raml_parser.gemspec +26 -0
  14. data/spec/examples/raml/documentation.raml +11 -0
  15. data/spec/examples/raml/external/box.raml +8473 -0
  16. data/spec/examples/raml/external/bug.raml +12 -0
  17. data/spec/examples/raml/external/github.raml +21650 -0
  18. data/spec/examples/raml/external/groups_and_nesting.raml +22 -0
  19. data/spec/examples/raml/external/instagram.yml +3369 -0
  20. data/spec/examples/raml/external/json_schema.json +18 -0
  21. data/spec/examples/raml/external/jukebox-api.raml +191 -0
  22. data/spec/examples/raml/external/jukebox-include-album-new.sample +8 -0
  23. data/spec/examples/raml/external/jukebox-include-album-retrieve.sample +30 -0
  24. data/spec/examples/raml/external/jukebox-include-album-songs.sample +14 -0
  25. data/spec/examples/raml/external/jukebox-include-album.schema +36 -0
  26. data/spec/examples/raml/external/jukebox-include-albums.sample +32 -0
  27. data/spec/examples/raml/external/jukebox-include-artist-albums.sample +42 -0
  28. data/spec/examples/raml/external/jukebox-include-artist-new.sample +5 -0
  29. data/spec/examples/raml/external/jukebox-include-artist-retrieve.sample +52 -0
  30. data/spec/examples/raml/external/jukebox-include-artist.schema +20 -0
  31. data/spec/examples/raml/external/jukebox-include-artists.sample +32 -0
  32. data/spec/examples/raml/external/jukebox-include-song-new.sample +5 -0
  33. data/spec/examples/raml/external/jukebox-include-song-retrieve.sample +15 -0
  34. data/spec/examples/raml/external/jukebox-include-song.schema +24 -0
  35. data/spec/examples/raml/external/jukebox-include-songs.sample +14 -0
  36. data/spec/examples/raml/external/linkedin-v1-single.yml +2671 -0
  37. data/spec/examples/raml/external/mule_sales_enablement.raml +148 -0
  38. data/spec/examples/raml/external/multiple-methods.raml +11 -0
  39. data/spec/examples/raml/external/named_parameters.raml +85 -0
  40. data/spec/examples/raml/external/requests-responses.raml +47 -0
  41. data/spec/examples/raml/external/resource_summary_spacing.raml +42 -0
  42. data/spec/examples/raml/external/simple.raml +233 -0
  43. data/spec/examples/raml/external/stripe.raml +12226 -0
  44. data/spec/examples/raml/external/test.raml +11 -0
  45. data/spec/examples/raml/external/twitter.raml +34284 -0
  46. data/spec/examples/raml/external/xml_example.xml +25 -0
  47. data/spec/examples/raml/external/xml_schema.xsd +50 -0
  48. data/spec/examples/raml/formparameters.raml +23 -0
  49. data/spec/examples/raml/headers.raml +15 -0
  50. data/spec/examples/raml/issue2.raml +51 -0
  51. data/spec/examples/raml/methods.raml +9 -0
  52. data/spec/examples/raml/parameters.raml +21 -0
  53. data/spec/examples/raml/parametersinflection.raml +21 -0
  54. data/spec/examples/raml/queryparameters.raml +14 -0
  55. data/spec/examples/raml/requestbodies.raml +21 -0
  56. data/spec/examples/raml/resources.raml +15 -0
  57. data/spec/examples/raml/resourcetypes.raml +16 -0
  58. data/spec/examples/raml/responses.raml +25 -0
  59. data/spec/examples/raml/securedby1.raml +20 -0
  60. data/spec/examples/raml/securedby2.raml +21 -0
  61. data/spec/examples/raml/securityschemes.raml +47 -0
  62. data/spec/examples/raml/simple.raml +6 -0
  63. data/spec/examples/raml/traits.raml +34 -0
  64. data/spec/examples/raml/uriparameters.raml +16 -0
  65. data/spec/examples/yaml/include1.yml +2 -0
  66. data/spec/examples/yaml/include2.yml +1 -0
  67. data/spec/examples/yaml/simple.yml +2 -0
  68. data/spec/examples/yaml/traversing.yml +11 -0
  69. data/spec/lib/raml_parser/yaml_parser_spec.rb +38 -0
  70. data/spec/lib/raml_parser_spec.rb +196 -0
  71. data/spec/spec_helper.rb +91 -0
  72. metadata +229 -0
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <job>
3
+ <id>1511685</id>
4
+ <expiration-timestamp>1304030488000</expiration-timestamp>
5
+ <company>
6
+ <id>229433</id>
7
+ <name>Cloudera</name>
8
+ </company>
9
+ <position>
10
+ <title>Technical Writer</title>
11
+ <location>
12
+ <name>San Francisco Bay Area</name>
13
+ <country>
14
+ <code>us</code>
15
+ </country>
16
+ </location>
17
+ </position>
18
+ <location-description>San Francisco or Palo Alto, CA</location-description>
19
+ <job-poster>
20
+ <id>hQ4ruu3J2q</id>
21
+ <first-name>Paul</first-name>
22
+ <last-name>Battaglia</last-name>
23
+ <headline>Technical Writer at Cloudera</headline>
24
+ </job-poster>
25
+ </job>
@@ -0,0 +1,50 @@
1
+ <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
2
+ <xs:element name="job">
3
+ <xs:complexType>
4
+ <xs:sequence>
5
+ <xs:element type="xs:int" name="id"/>
6
+ <xs:element type="xs:long" name="expiration-timestamp"/>
7
+ <xs:element name="company">
8
+ <xs:complexType>
9
+ <xs:sequence>
10
+ <xs:element type="xs:int" name="id"/>
11
+ <xs:element type="xs:string" name="name"/>
12
+ </xs:sequence>
13
+ </xs:complexType>
14
+ </xs:element>
15
+ <xs:element name="position">
16
+ <xs:complexType>
17
+ <xs:sequence>
18
+ <xs:element type="xs:string" name="title"/>
19
+ <xs:element name="location">
20
+ <xs:complexType>
21
+ <xs:sequence>
22
+ <xs:element type="xs:string" name="name"/>
23
+ <xs:element name="country">
24
+ <xs:complexType>
25
+ <xs:sequence>
26
+ <xs:element type="xs:string" name="code"/>
27
+ </xs:sequence>
28
+ </xs:complexType>
29
+ </xs:element>
30
+ </xs:sequence>
31
+ </xs:complexType>
32
+ </xs:element>
33
+ </xs:sequence>
34
+ </xs:complexType>
35
+ </xs:element>
36
+ <xs:element type="xs:string" name="location-description"/>
37
+ <xs:element name="job-poster">
38
+ <xs:complexType>
39
+ <xs:sequence>
40
+ <xs:element type="xs:string" name="id"/>
41
+ <xs:element type="xs:string" name="first-name"/>
42
+ <xs:element type="xs:string" name="last-name"/>
43
+ <xs:element type="xs:string" name="headline"/>
44
+ </xs:sequence>
45
+ </xs:complexType>
46
+ </xs:element>
47
+ </xs:sequence>
48
+ </xs:complexType>
49
+ </xs:element>
50
+ </xs:schema>
@@ -0,0 +1,23 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ version: v123
6
+ /a:
7
+ post:
8
+ body:
9
+ application/x-www-form-urlencoded:
10
+ formParameters:
11
+ from:
12
+ description: FROM1
13
+ to:
14
+ description: TO1
15
+ /b:
16
+ post:
17
+ body:
18
+ multipart/form-data:
19
+ formParameters:
20
+ from:
21
+ description: FROM2
22
+ to:
23
+ description: TO2
@@ -0,0 +1,15 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ /a:
6
+ get:
7
+ headers:
8
+ X-Foobar-Ping:
9
+ description: Ping
10
+ responses:
11
+ 200:
12
+ headers:
13
+ X-Foobar-Pong:
14
+ displayName: PingPong
15
+ description: Pong
@@ -0,0 +1,51 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: GitHub API
4
+ baseUri: https://api.github.com
5
+ version: v3
6
+ traits:
7
+ - base:
8
+ responses:
9
+ 404:
10
+ description: Not found
11
+ body:
12
+ application/json:
13
+ example: |
14
+ {
15
+ "status_code": 404,
16
+ "message": "Not found"
17
+ }
18
+ 500:
19
+ description: Internal server error
20
+ body:
21
+ application/json:
22
+ example: |
23
+ {
24
+ "status_code": 500,
25
+ "message": "Internal server error"
26
+ }
27
+ resourceTypes:
28
+ - collection:
29
+ post:
30
+ responses:
31
+ 404:
32
+ description: Not found
33
+ body:
34
+ application/json:
35
+ example: |
36
+ {
37
+ "status_code": 404,
38
+ "message": "Not found"
39
+ }
40
+ 500:
41
+ description: Internal server error
42
+ body:
43
+ application/json:
44
+ example: |
45
+ {
46
+ "status_code": 500,
47
+ "message": "Internal server error"
48
+ }
49
+ /users/{username}:
50
+ type: collection
51
+ get:
@@ -0,0 +1,9 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ /a:
6
+ get:
7
+ /b:
8
+ get:
9
+ displayName: This is /a/b
@@ -0,0 +1,21 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ traits:
6
+ - first:
7
+ description: <<resourcePath>> and <<resourcePathName>> and <<methodName>> and <<fooBar>>
8
+ queryParameters:
9
+ <<methodName>>:
10
+ description: Applepie
11
+ resourceTypes:
12
+ - second:
13
+ description: <<resourcePath>> and <<resourcePathName>> and <<applePie>>
14
+ /first:
15
+ get:
16
+ is: [ first: { fooBar: Hello } ]
17
+ /second:
18
+ type: { second: { applePie: World } }
19
+ /third:
20
+ /fourth:
21
+ type: { second: { applePie: Finish } }
@@ -0,0 +1,21 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ traits:
6
+ - keep:
7
+ description: Keep <<resourcePathName>>
8
+ - sing:
9
+ description: Sing <<resourcePathName | !singularize>>
10
+ - plu:
11
+ description: Plu <<resourcePathName | !pluralize>>
12
+ /userName:
13
+ get:
14
+ is: [ keep ]
15
+ post:
16
+ is: [ plu ]
17
+ /passwords:
18
+ get:
19
+ is: [ keep ]
20
+ post:
21
+ is: [ sing ]
@@ -0,0 +1,14 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ /a:
6
+ get:
7
+ queryParameters:
8
+ q1:
9
+ /b:
10
+ get:
11
+ queryParameters:
12
+ q2:
13
+ displayName: This is the second query parameter
14
+ type: integer
@@ -0,0 +1,21 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ /first:
6
+ post:
7
+ body:
8
+ application/json:
9
+ example: |
10
+ {
11
+ "foo": "bar"
12
+ }
13
+ text/xml:
14
+ put:
15
+ body:
16
+ application/json:
17
+ example: |
18
+ {
19
+ "status": "not found",
20
+ "message: "Resource could not be found"
21
+ }
@@ -0,0 +1,15 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ /first:
6
+ get:
7
+ /second:
8
+ /third:
9
+ displayName: This is the third
10
+ /with:
11
+ /{uri}:
12
+ /{params}:
13
+ uriParameters:
14
+ params:
15
+ displayName: This are the params
@@ -0,0 +1,16 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ resourceTypes:
6
+ - collection:
7
+ description: A collection
8
+ get:
9
+ description: Get all items
10
+ post:
11
+ description: Create a new item
12
+ /a:
13
+ type: collection
14
+ put:
15
+ post:
16
+ description: Overriden
@@ -0,0 +1,25 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ /first:
6
+ get:
7
+ responses:
8
+ 200:
9
+ displayName: The first
10
+ description: This is the first
11
+ body:
12
+ application/json:
13
+ example: |
14
+ {
15
+ "foo": "bar"
16
+ }
17
+ text/xml:
18
+ 404:
19
+ body:
20
+ application/json:
21
+ example: |
22
+ {
23
+ "status": "not found",
24
+ "message: "Resource could not be found"
25
+ }
@@ -0,0 +1,20 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ securitySchemes:
6
+ - oauth_1_0:
7
+ type: OAuth 1.0
8
+ - oauth_2_0:
9
+ type: OAuth 2.0
10
+ /first:
11
+ get:
12
+ securedBy: [oauth_1_0]
13
+ post:
14
+ securedBy: [oauth_2_0]
15
+ /second:
16
+ securedBy: [oauth_1_0]
17
+ get:
18
+ securedBy: [null, oauth_2_0]
19
+ post:
20
+ securedBy: [oauth_2_0]
@@ -0,0 +1,21 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ securedBy: [oauth_2_0]
6
+ securitySchemes:
7
+ - oauth_1_0:
8
+ type: OAuth 1.0
9
+ - oauth_2_0:
10
+ type: OAuth 2.0
11
+ /first:
12
+ get:
13
+ securedBy: [oauth_1_0]
14
+ post:
15
+ securedBy: [oauth_2_0]
16
+ /second:
17
+ securedBy: [oauth_1_0]
18
+ get:
19
+ securedBy: [null, oauth_2_0]
20
+ post:
21
+ securedBy: [oauth_2_0]
@@ -0,0 +1,47 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ securitySchemes:
6
+ - oauth_2_0:
7
+ description: |
8
+ Dropbox supports OAuth 2.0 for authenticating all API requests.
9
+ type: OAuth 2.0
10
+ describedBy:
11
+ headers:
12
+ Authorization:
13
+ description: |
14
+ Used to send a valid OAuth 2 access token. Do not use
15
+ with the "access_token" query string parameter.
16
+ type: string
17
+ queryParameters:
18
+ access_token:
19
+ description: |
20
+ Used to send a valid OAuth 2 access token. Do not use together with
21
+ the "Authorization" header
22
+ type: string
23
+ responses:
24
+ 401:
25
+ description: |
26
+ Bad or expired token. This can happen if the user or Dropbox
27
+ revoked or expired an access token. To fix, you should re-
28
+ authenticate the user.
29
+ 403:
30
+ description: |
31
+ Bad OAuth request (wrong consumer key, bad nonce, expired
32
+ timestamp...). Unfortunately, re-authenticating the user won't help here.
33
+ settings:
34
+ authorizationUri: https://www.dropbox.com/1/oauth2/authorize
35
+ accessTokenUri: https://api.dropbox.com/1/oauth2/token
36
+ authorizationGrants: [ code, token ]
37
+ - oauth_1_0:
38
+ description: |
39
+ OAuth 1.0 continues to be supported for all API requests, but OAuth 2.0 is now preferred.
40
+ type: OAuth 1.0
41
+ settings:
42
+ requestTokenUri: https://api.dropbox.com/1/oauth/request_token
43
+ authorizationUri: https://www.dropbox.com/1/oauth/authorize
44
+ tokenCredentialsUri: https://api.dropbox.com/1/oauth/access_token
45
+ - customHeader:
46
+ description: |
47
+ A custom
@@ -0,0 +1,6 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ version: v123
6
+ mediaType: application/json
@@ -0,0 +1,34 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://localhost:3000
5
+ traits:
6
+ - searchable:
7
+ displayName: Foo
8
+ description: This is searchable
9
+ queryParameters:
10
+ q:
11
+ - sortable:
12
+ description: This is sortable
13
+ queryParameters:
14
+ key:
15
+ order:
16
+ /a:
17
+ get:
18
+ is: [ searchable, sortable ]
19
+ /b:
20
+ get:
21
+ is: [ searchable, sortable ]
22
+ displayName: /a/b
23
+ description: This is resource /a/b
24
+ queryParameters:
25
+ sort:
26
+ q:
27
+ displayName: This is the search term
28
+ /c:
29
+ is: [ sortable ]
30
+ get:
31
+ /d:
32
+ is: [ sortable ]
33
+ get:
34
+ is: [ searchable ]