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,18 @@
1
+ {
2
+ "title": "Example Schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "firstName": {
6
+ "type": "string"
7
+ },
8
+ "lastName": {
9
+ "type": "string"
10
+ },
11
+ "age": {
12
+ "description": "Age in years",
13
+ "type": "integer",
14
+ "minimum": 0
15
+ }
16
+ },
17
+ "required": ["firstName", "lastName"]
18
+ }
@@ -0,0 +1,191 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Jukebox API
4
+ baseUri: http://jukebox.api.com
5
+ version: v1
6
+
7
+ schemas:
8
+ - song: !include jukebox-include-song.schema
9
+ - artist: !include jukebox-include-artist.schema
10
+ - album: !include jukebox-include-album.schema
11
+
12
+
13
+ resourceTypes:
14
+ - readOnlyCollection:
15
+ description: Collection of available <<resourcePathName>> in Jukebox.
16
+ get:
17
+ description: Get a list of <<resourcePathName>>.
18
+ responses:
19
+ 200:
20
+ body:
21
+ application/json:
22
+ example: |
23
+ <<exampleCollection>>
24
+ - collection:
25
+ description: Collection of available <<resourcePathName>> in Jukebox.
26
+ get:
27
+ description: Get a list of <<resourcePathName>>.
28
+ responses:
29
+ 200:
30
+ body:
31
+ application/json:
32
+ example: |
33
+ <<exampleCollection>>
34
+ post:
35
+ description: |
36
+ Add a new <<resourcePathName|!singularize>> to Jukebox.
37
+ queryParameters:
38
+ access_token:
39
+ description: "The access token provided by the authentication application"
40
+ example: AABBCCDD
41
+ required: true
42
+ type: string
43
+ body:
44
+ application/json:
45
+ schema: <<resourcePathName|!singularize>>
46
+ example: |
47
+ <<exampleItem>>
48
+ responses:
49
+ 200:
50
+ body:
51
+ application/json:
52
+ example: |
53
+ { "message": "The <<resourcePathName|!singularize>> has been properly entered" }
54
+ - collection-item:
55
+ description: Entity representing a <<resourcePathName|!singularize>>
56
+ get:
57
+ description: |
58
+ Get the <<resourcePathName|!singularize>>
59
+ with <<resourcePathName|!singularize>>Id =
60
+ {<<resourcePathName|!singularize>>Id}
61
+ responses:
62
+ 200:
63
+ body:
64
+ application/json:
65
+ example: |
66
+ <<exampleItem>>
67
+ 404:
68
+ body:
69
+ application/json:
70
+ example: |
71
+ {"message": "<<resourcePathName|!singularize>> not found" }
72
+ traits:
73
+ - searchable:
74
+ queryParameters:
75
+ query:
76
+ description: |
77
+ JSON array [{"field1","value1","operator1"},{"field2","value2","operator2"},...,{"fieldN","valueN","operatorN"}] <<description>>
78
+ example: |
79
+ <<example>>
80
+ - orderable:
81
+ queryParameters:
82
+ orderBy:
83
+ description: |
84
+ Order by field: <<fieldsList>>
85
+ type: string
86
+ required: false
87
+ order:
88
+ description: Order
89
+ enum: [desc, asc]
90
+ default: desc
91
+ required: false
92
+ - pageable:
93
+ queryParameters:
94
+ offset:
95
+ description: Skip over a number of elements by specifying an offset value for the query
96
+ type: integer
97
+ required: false
98
+ example: 20
99
+ default: 0
100
+ limit:
101
+ description: Limit the number of elements on the response
102
+ type: integer
103
+ required: false
104
+ example: 80
105
+ default: 10
106
+
107
+ /songs:
108
+ type:
109
+ collection:
110
+ exampleCollection: !include jukebox-include-songs.sample
111
+ exampleItem: !include jukebox-include-song-new.sample
112
+ get:
113
+ is: [
114
+ searchable: {description: "with valid searchable fields: songTitle", example: "[\"songTitle\", \"Get L\", \"like\"]"},
115
+ orderable: {fieldsList: "songTitle"},
116
+ pageable
117
+ ]
118
+ /{songId}:
119
+ type:
120
+ collection-item:
121
+ exampleItem: !include jukebox-include-song-retrieve.sample
122
+ /file-content:
123
+ description: The file to be reproduced by the client
124
+ get:
125
+ description: Get the file content
126
+ responses:
127
+ 200:
128
+ body:
129
+ binary/octet-stream:
130
+ post:
131
+ description: |
132
+ Enters the file content for an existing song entity.
133
+
134
+ The song needs to be created for the `/songs/{songId}/file-content` to exist.
135
+ You can use this second resource to get and post the file to reproduce.
136
+
137
+ Use the "binary/octet-stream" content type to specify the content from any consumer (excepting web-browsers).
138
+ Use the "multipart-form/data" content type to upload a file which content will become the file-content
139
+ body:
140
+ binary/octet-stream:
141
+ multipart/form-data:
142
+ formParameters:
143
+ file:
144
+ description: The file to be uploaded
145
+ required: true
146
+ type: file
147
+ /artists:
148
+ type:
149
+ collection:
150
+ exampleCollection: !include jukebox-include-artists.sample
151
+ exampleItem: !include jukebox-include-artist-new.sample
152
+ get:
153
+ is: [
154
+ searchable: {description: "with valid searchable fields: countryCode", example: "[\"countryCode\", \"FRA\", \"equals\"]"},
155
+ orderable: {fieldsList: "artistName, nationality"},
156
+ pageable
157
+ ]
158
+ /{artistId}:
159
+ type:
160
+ collection-item:
161
+ exampleItem: !include jukebox-include-artist-retrieve.sample
162
+ /albums:
163
+ type:
164
+ readOnlyCollection:
165
+ exampleCollection: !include jukebox-include-artist-albums.sample
166
+ description: Collection of albulms belonging to the artist
167
+ get:
168
+ description: Get a specific artist's albums list
169
+ is: [orderable: {fieldsList: "albumName"}, pageable]
170
+ /albums:
171
+ type:
172
+ collection:
173
+ exampleCollection: !include jukebox-include-albums.sample
174
+ exampleItem: !include jukebox-include-album-new.sample
175
+ get:
176
+ is: [
177
+ searchable: {description: "with valid searchable fields: genreCode", example: "[\"genreCode\", \"ELE\", \"equals\"]"},
178
+ orderable: {fieldsList: "albumName, genre"},
179
+ pageable
180
+ ]
181
+ /{albumId}:
182
+ type:
183
+ collection-item:
184
+ exampleItem: !include jukebox-include-album-retrieve.sample
185
+ /songs:
186
+ type:
187
+ readOnlyCollection:
188
+ exampleCollection: !include jukebox-include-album-songs.sample
189
+ get:
190
+ is: [orderable: {fieldsList: "songTitle"}]
191
+ description: Get the list of songs for the album with `albumId = {albumId}`
@@ -0,0 +1,8 @@
1
+ {
2
+ "albumId": "183100e3-0e2b-4404-a716-66104d440550",
3
+ "albumName": "Random Access Memories",
4
+ "year": "2013",
5
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/a/a7/Random_Access_Memories.jpg",
6
+ "genreCode": "ELE",
7
+ "artistId": "110e8300-e32b-41d4-a716-664400445500"
8
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "albumId": "183100e3-0e2b-4404-a716-66104d440550",
3
+ "albumName": "Random Access Memories",
4
+ "year": "2013",
5
+ "genre": "Electric Funk",
6
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/a/a7/Random_Access_Memories.jpg",
7
+ "genre": {
8
+ "countryCode": "ELE",
9
+ "countryName": "Electronict"
10
+ },
11
+ "songs": [
12
+ {
13
+ "songId": "550e8400-e29b-41d4-a716-446655440000",
14
+ "songTitle": "Get Lucky"
15
+ },
16
+ {
17
+ "songId": "550e8400-e29b-41d4-a716-446655440111",
18
+ "songTitle": "Loose yourself to dance"
19
+ },
20
+ {
21
+ "songId": "550e8400-e29b-41d4-a716-446655440222",
22
+ "songTitle": "Gio sorgio by Moroder"
23
+ }
24
+ ],
25
+ "artist": {
26
+ "artistId": "110e8300-e32b-41d4-a716-664400445500",
27
+ "artistName": "Daft Punk",
28
+ "imageURL": "http://travelhymns.com/wp-content/uploads/2013/06/random-access-memories1.jpg"
29
+ }
30
+ }
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "songId": "550e8400-e29b-41d4-a716-446655440000",
4
+ "songTitle": "Get Lucky"
5
+ },
6
+ {
7
+ "songId": "550e8400-e29b-41d4-a716-446655440111",
8
+ "songTitle": "Loose yourself to dance"
9
+ },
10
+ {
11
+ "songId": "550e8400-e29b-41d4-a716-446655440222",
12
+ "songTitle": "Gio sorgio by Moroder"
13
+ }
14
+ ]
@@ -0,0 +1,36 @@
1
+ {
2
+ "type": "object",
3
+ "$schema": "http://json-schema.org/draft-03/schema",
4
+ "id": "http://jsonschema.net",
5
+ "required":false,
6
+ "properties": {
7
+ "albumId": {
8
+ "type": "string",
9
+ "required":true,
10
+ "minLength": 36,
11
+ "maxLength": 36
12
+ },
13
+ "albumName": {
14
+ "type": "string",
15
+ "required": true
16
+ },
17
+ "year": {
18
+ "type": "string",
19
+ "required": false
20
+ },
21
+ "iamgeURL": {
22
+ "type": "string",
23
+ "required": false
24
+ },
25
+ "genreCode": {
26
+ "type": "string",
27
+ "required": true
28
+ },
29
+ "artistId": {
30
+ "type": "string",
31
+ "required":true,
32
+ "minLength": 36,
33
+ "maxLength": 36
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,32 @@
1
+ [
2
+ {
3
+ "albumId": "183100e3-0e2b-4404-a716-66104d440550",
4
+ "albumName": "Random Access Memories",
5
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/a/a7/Random_Access_Memories.jpg",
6
+ "artistId": "110e8300-e32b-41d4-a716-664400445500",
7
+ "genre": {
8
+ "countryCode": "ELE",
9
+ "countryName": "Electronic"
10
+ }
11
+ },
12
+ {
13
+ "albumId": "183100e3-0e2b-4404-3123-66111d4de520",
14
+ "albumName": "OK Computer",
15
+ "imageURL": "http://www.greenplastic.com/dev/wp-content/uploads/2010/12/ok-computer.jpg",
16
+ "artistId": "11032be3-41d4-4455-a716-664400a71600",
17
+ "genre": {
18
+ "countryCode": "ALT",
19
+ "countryName": "Alternative Rock"
20
+ }
21
+ },
22
+ {
23
+ "albumId": "183100e3-cccc-4404-1111-63204d64coda",
24
+ "albumName": "The Dark Side of the Moon",
25
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/3/3b/Dark_Side_of_the_Moon.png",
26
+ "artistId": "110e8300-e32b-41d4-a716-229932554400",
27
+ "genre": {
28
+ "countryCode": "PRO",
29
+ "countryName": "Progressive Rock"
30
+ }
31
+ }
32
+ ]
@@ -0,0 +1,42 @@
1
+ [
2
+ {
3
+ "albumId": "183100e3-0e2b-4404-a716-66104d440550",
4
+ "albumName": "Random Access Memories",
5
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/a/a7/Random_Access_Memories.jpg"
6
+ },
7
+ {
8
+ "albumId": "183100e3-0e2b-4404-a716-66104d440551",
9
+ "albumName": "TRON: Legacy R3CONF1GUR3D",
10
+ "imageURL": "http://ecx.images-amazon.com/images/I/51Tvo-iArBL.jpg"
11
+ },
12
+ {
13
+ "albumId": "183100e3-0e2b-4404-a716-66104d440552",
14
+ "albumName": "TRON: Legacy",
15
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/3/39/Tron_Legacy_Soundtrack.jpg"
16
+ },
17
+ {
18
+ "albumId": "183100e3-0e2b-4404-a716-66104d440553",
19
+ "albumName": "Alive",
20
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/4/49/Daft_Punk_Alive_2007.JPG"
21
+ },
22
+ {
23
+ "albumId": "183100e3-0e2b-4404-a716-66104d440554",
24
+ "albumName": "Musique Vol. 1",
25
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/a/ab/Musique_Vol._1_1993%E2%80%932005.png"
26
+ },
27
+ {
28
+ "albumId": "183100e3-0e2b-4404-a716-66104d440555",
29
+ "albumName": "Human After All",
30
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/0/0d/Humanafterall.jpg"
31
+ },
32
+ {
33
+ "albumId": "183100e3-0e2b-4404-a716-66104d440556",
34
+ "albumName": "Daft Club",
35
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/f/fc/Daftclub.jpg"
36
+ },
37
+ {
38
+ "albumId": "183100e3-0e2b-4404-a716-66104d440557",
39
+ "albumName": "Discovery",
40
+ "imageURL": "http://ecx.images-amazon.com/images/I/71bsHTr6idL._SL1500_.jpg"
41
+ }
42
+ ]
@@ -0,0 +1,5 @@
1
+ {
2
+ "artistName": "Daft Punk",
3
+ "description": "French electronic music duo consisting of musicians Guy-Manuel de Homem-Christo and Thomas Bangalter",
4
+ "imageURL": "http://travelhymns.com/wp-content/uploads/2013/06/random-access-memories1.jpg"
5
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "artistId": "110e8300-e32b-41d4-a716-664400445500",
3
+ "artistName": "Daft Punk",
4
+ "description": "French electronic music duo consisting of musicians Guy-Manuel de Homem-Christo and Thomas Bangalter",
5
+ "imageURL": "http://travelhymns.com/wp-content/uploads/2013/06/random-access-memories1.jpg",
6
+ "nationality": {
7
+ "countryCode": "FRA",
8
+ "countryName": "France"
9
+ },
10
+ "albums": [
11
+ {
12
+ "albumId": "183100e3-0e2b-4404-a716-66104d440550",
13
+ "albumName": "Random Access Memories",
14
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/a/a7/Random_Access_Memories.jpg"
15
+ },
16
+ {
17
+ "albumId": "183100e3-0e2b-4404-a716-66104d440551",
18
+ "albumName": "TRON: Legacy R3CONF1GUR3D",
19
+ "imageURL": "http://ecx.images-amazon.com/images/I/51Tvo-iArBL.jpg"
20
+ },
21
+ {
22
+ "albumId": "183100e3-0e2b-4404-a716-66104d440552",
23
+ "albumName": "TRON: Legacy",
24
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/3/39/Tron_Legacy_Soundtrack.jpg"
25
+ },
26
+ {
27
+ "albumId": "183100e3-0e2b-4404-a716-66104d440553",
28
+ "albumName": "Alive",
29
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/4/49/Daft_Punk_Alive_2007.JPG"
30
+ },
31
+ {
32
+ "albumId": "183100e3-0e2b-4404-a716-66104d440554",
33
+ "albumName": "Musique Vol. 1",
34
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/a/ab/Musique_Vol._1_1993%E2%80%932005.png"
35
+ },
36
+ {
37
+ "albumId": "183100e3-0e2b-4404-a716-66104d440555",
38
+ "albumName": "Human After All",
39
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/0/0d/Humanafterall.jpg"
40
+ },
41
+ {
42
+ "albumId": "183100e3-0e2b-4404-a716-66104d440556",
43
+ "albumName": "Daft Club",
44
+ "imageURL": "http://upload.wikimedia.org/wikipedia/en/f/fc/Daftclub.jpg"
45
+ },
46
+ {
47
+ "albumId": "183100e3-0e2b-4404-a716-66104d440557",
48
+ "albumName": "Discovery",
49
+ "imageURL": "http://ecx.images-amazon.com/images/I/71bsHTr6idL._SL1500_.jpg"
50
+ }
51
+ ]
52
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "type": "object",
3
+ "$schema": "http://json-schema.org/draft-03/schema",
4
+ "id": "http://jsonschema.net",
5
+ "required":false,
6
+ "properties": {
7
+ "artistName": {
8
+ "type": "string",
9
+ "required":true
10
+ },
11
+ "description": {
12
+ "type": "string",
13
+ "required": false
14
+ },
15
+ "imageURL": {
16
+ "type": "string",
17
+ "required": false
18
+ }
19
+ }
20
+ }