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,148 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: "Muse: Mule Sales Enablement API"
4
+ version: v1
5
+ baseUri: http://vast-coast-7974.herokuapp.com/muse
6
+ schemas:
7
+ - presentation: |
8
+ { "$schema": "http://json-schema.org/draft-03/schema",
9
+ "type": "object",
10
+ "description": "A product presentation",
11
+ "properties": {
12
+ "id": { "type": "string" },
13
+ "title": { "type": "string" },
14
+ "description": { "type": "string" },
15
+ "fileUrl": { "type": "string" },
16
+ "productId": { "type": "string" }
17
+ },
18
+ "required": [ "id", "title", "fileUrl", "productId" ]
19
+ }
20
+ - product: |
21
+ { "$schema": "http://json-schema.org/draft-03/schema",
22
+ "type": "object",
23
+ "description": "A Product",
24
+ "properties": {
25
+ "id": { "type": "string" },
26
+ "name": { "type": "string" },
27
+ "description": { "type": "string" },
28
+ "imageUrl": { "type": "string" },
29
+ "region": { "type": "string" }
30
+ },
31
+ "required": [ "id", "name", "region" ]
32
+ }
33
+ resourceTypes:
34
+ - base:
35
+ get?:
36
+ responses: &standardResponses
37
+ 200:
38
+ description: OK
39
+ put?:
40
+ responses: *standardResponses
41
+ patch?:
42
+ responses: *standardResponses
43
+ post?:
44
+ responses:
45
+ 201:
46
+ description: Created
47
+ delete?:
48
+ responses: *standardResponses
49
+ - collection:
50
+ type: base
51
+ get:
52
+ is: [ paged ]
53
+ post:
54
+ - typedCollection:
55
+ type: collection
56
+ get:
57
+ responses:
58
+ 200:
59
+ body:
60
+ application/json:
61
+ schema: <<schema>>
62
+ post:
63
+ body:
64
+ application/json:
65
+ schema: <<schema>>
66
+ responses:
67
+ 201:
68
+ body:
69
+ application/json:
70
+ schema: <<schema>>
71
+ - member:
72
+ type: base
73
+ get:
74
+ put:
75
+ patch:
76
+ delete:
77
+ - typedMember:
78
+ type: member
79
+ get:
80
+ responses:
81
+ 200:
82
+ body:
83
+ application/json:
84
+ schema: <<schema>>
85
+ put:
86
+ body:
87
+ application/json:
88
+ schema: <<schema>>
89
+ responses:
90
+ 200:
91
+ body:
92
+ application/json:
93
+ schema: <<schema>>
94
+ patch:
95
+ body:
96
+ application/json:
97
+ schema: <<schema>>
98
+ responses:
99
+ 200:
100
+ body:
101
+ application/json:
102
+ schema: <<schema>>
103
+ delete:
104
+ traits:
105
+ - paged:
106
+ displayName: paged
107
+ queryParameters:
108
+ start:
109
+ displayName: start
110
+ description: The first page to return
111
+ type: number
112
+ pages:
113
+ displayName: pages
114
+ description: The number of pages to return
115
+ type: number
116
+ - secured:
117
+ displayName: secured
118
+ headers:
119
+ Authorization:
120
+ description: The auth token for this request
121
+ responses:
122
+ 401:
123
+ description: Unauthorized
124
+ /presentations: &presentations
125
+ type: { typedCollection: { schema: presentation } }
126
+ is: [ secured ]
127
+ get:
128
+ queryParameters:
129
+ title:
130
+ type: string
131
+ displayName: title
132
+ description: Filter by title
133
+ /{presentationId}:
134
+ type: { typedMember: { schema: presentation } }
135
+ is: [ secured ]
136
+ /products:
137
+ type: { typedCollection: { schema: product } }
138
+ is: [ secured ]
139
+ get:
140
+ queryParameters:
141
+ region:
142
+ type: string
143
+ displayName: region
144
+ description: Filter by region
145
+ /{productId}:
146
+ type: { typedMember: { schema: product } }
147
+ is: [ secured ]
148
+ /presentations: *presentations
@@ -0,0 +1,11 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: #{test_api_uri}
5
+ /resource:
6
+ get: !!null
7
+ post: !!null
8
+ /another-resource:
9
+ get: !!null
10
+ put: !!null
11
+ delete: !!null
@@ -0,0 +1,85 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://www.example.com/
5
+ /resource:
6
+ get:
7
+ queryParameters:
8
+ displayNameAndTypeDefaults:
9
+ displayNameProvided:
10
+ displayName: 'Display Name Provided'
11
+ withType:
12
+ type: integer
13
+ withPattern:
14
+ pattern: /some regex/
15
+ minLength:
16
+ minLength: 8
17
+ maxLength:
18
+ maxLength: 20
19
+ minAndMaxLength:
20
+ minLength: 8
21
+ maxLength: 20
22
+ minimum:
23
+ type: number
24
+ minimum: 8
25
+ maximum:
26
+ type: number
27
+ maximum: 20
28
+ minAndMaximum:
29
+ type: number
30
+ minimum: 8
31
+ maximum: 20
32
+ repeat:
33
+ repeat: true
34
+ simpleShortDescription:
35
+ description: |
36
+ This parameter is used to do something.
37
+ simpleLongDescription:
38
+ description: |
39
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
40
+ eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
41
+ minim veniam, quis nostrud exercitation ullamco laboris nisi ut
42
+ aliquip ex ea commodo consequat. Duis aute irure dolor in
43
+ reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
44
+ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
45
+ culpa qui officia deserunt mollit anim id est laborum.
46
+ markdownDescription:
47
+ description: |
48
+ An explanation of the purpose of this parameter, in **Markdown**!
49
+
50
+ # We can have headers
51
+
52
+ And text with *all* sorts of formatting.
53
+
54
+ * Such
55
+ * as
56
+ * lists
57
+ example:
58
+ example: 1a79a4d60de6718e8e5b326e338ae533
59
+ default:
60
+ default: 0
61
+ descriptionAndExample:
62
+ description: This parameter is used to do something.
63
+ example: 154
64
+ required:
65
+ required: true
66
+ enum:
67
+ enum:
68
+ - one
69
+ - two
70
+ - three
71
+ combo:
72
+ required: true
73
+ enum:
74
+ - any
75
+ - all
76
+ - exact match
77
+ description: This parameter does something
78
+ anotherCombo:
79
+ required: true
80
+ type: integer
81
+ minimum: 5
82
+ maximum: 20
83
+ default: 5
84
+ example: 18
85
+ description: This explains the function of this parameter.
@@ -0,0 +1,47 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://example.com
5
+ schemas:
6
+ - an_xml_schema: !include xml_schema.xsd
7
+ - a_json_schema: !include json_schema.json
8
+ /resource:
9
+ post:
10
+ headers:
11
+ X-Some-Header:
12
+ description: This is an example header
13
+ body:
14
+ text/xml:
15
+ schema: an_xml_schema
16
+ example: !include xml_example.xml
17
+ application/json:
18
+ schema: a_json_schema
19
+ example: |
20
+ { "figure": true,
21
+ "out": true,
22
+ "your": true,
23
+ "life": true
24
+ }
25
+ responses:
26
+ 200:
27
+ description: |
28
+ *Success* description
29
+ headers:
30
+ X-Some-Header:
31
+ type: integer
32
+ example: 5
33
+ description: A *description* of some header sent as part of the **response**.
34
+ 404:
35
+ description: |
36
+ *Error* description
37
+ body:
38
+ text/xml:
39
+ example: |
40
+ <api-response><status>Error</status></api-response>
41
+ schema: an_xml_schema
42
+
43
+ /sub:
44
+ description: hi
45
+ get:
46
+ description: |
47
+ ### WHAT
@@ -0,0 +1,42 @@
1
+ #%RAML 0.8
2
+ # Use this RAML with a very narrow console to see how the resource summary wraps
3
+ # given the length/presence/absence of various elements
4
+ title: Example
5
+ resourceTypes:
6
+ - someType: {}
7
+ traits:
8
+ - someTrait: {}
9
+ /resource/with/a/very/long/name/that/causes/it/to/wrap/which/looks/bad/because:
10
+ /short:
11
+ /short:
12
+ /short:
13
+ /the/line/height/is/small:
14
+ get:
15
+ /some/more/with/ascenders:
16
+ type: someType
17
+ /and/padaqalag/with/methods:
18
+ type: someType
19
+ is: [someTrait]
20
+ get:
21
+ post:
22
+ put:
23
+ delete:
24
+ /and/padaqalaga/with/description:
25
+ type: someType
26
+ is: [someTrait]
27
+ description: |
28
+ Some text I wrote
29
+
30
+ And some more text
31
+
32
+ Plus suppose I wrote a bunch of long text that wraps and makes it look like a real paragraph
33
+ get:
34
+ post:
35
+ put:
36
+ delete:
37
+ /short:
38
+ type: someType
39
+ /short-with-methods:
40
+ type: someType
41
+ get:
42
+ post:
@@ -0,0 +1,233 @@
1
+ #%RAML 0.8
2
+ ---
3
+ title: Example API
4
+ baseUri: http://example.com
5
+ securitySchemes:
6
+ - basic:
7
+ type: Basic Authentication
8
+ traits:
9
+ - secured:
10
+ description: Some requests require authentication
11
+ - unsecured:
12
+ description: This is not secured
13
+ - catpictures:
14
+ description: requires cat headers
15
+ - anotherTrait: {}
16
+ - andAnotherTrait: {}
17
+ - andYetAnotherTrait: {}
18
+ - aFinalTrait: {}
19
+ - someParameterizedTrait:
20
+ description: <<someParameterName>>
21
+ resourceTypes:
22
+ - longCollectionName:
23
+ description: |
24
+ This is a description. It can be long.
25
+
26
+ # Headers
27
+
28
+ It can have headers, and _italic_, and **bold** text.
29
+
30
+ # Length
31
+
32
+ Because it is arbitrary markdown, it can be arbitrarily long.
33
+ documentation:
34
+ - title: Getting Started
35
+ content: |
36
+ # Header
37
+ Content
38
+ ## Subheader
39
+ **Bolded content**
40
+ /resource:
41
+ displayName: First One
42
+ is: [secured]
43
+ options:
44
+ responses:
45
+ 200:
46
+ connect:
47
+ responses:
48
+ 200:
49
+ trace:
50
+ responses:
51
+ 200:
52
+ patch:
53
+ responses:
54
+ 200:
55
+ delete:
56
+ responses:
57
+ 200:
58
+ 201:
59
+ 203:
60
+ put:
61
+ responses:
62
+ 200:
63
+ 201:
64
+ 203:
65
+ get:
66
+ description: get the first one
67
+ headers:
68
+ x-custom:
69
+ responses:
70
+ 200:
71
+ /{resourceId}:
72
+ description: This is a resource description *with* some _markdown_ embedded in it
73
+ uriParameters:
74
+ resourceId:
75
+ required: true
76
+ description: Which resoure would you like to view
77
+ get:
78
+ description: |
79
+ Instagram’s API uses the [OAuth 2.0 protocol](http://tools.ietf.org/html/draft-ietf-oauth-v2-12) for simple, but effective authentication and authorization. OAuth 2.0 is much easier to use than previous schemes; developers can start using the Instagram API almost immediately. The one thing to keep in mind is that all requests to the API must be made over SSL (https:// not http://)
80
+
81
+ ## Do you need to authenticate?
82
+
83
+ For the most part, Instagram’s API only requires the use of a _client_id). A client_id simply associates your server, script, or program with a specific application. However, some requests require authentication - specifically requests made on behalf of a user. Authenticated requests require an _access_token_. These tokens are unique to a user and should be stored securely. Access tokens may expire at any time in the future.
84
+
85
+ Note that in many situations, you may not need to authenticate users at all. For instance, you may request popular photos without authenticating (i.e. you do not need to provide an access_token; just use your client ID with your request). We only require authentication in cases where your application is making requests on behalf of a user (commenting, liking, browsing a user’s feed, etc.).
86
+
87
+ ## Receiving an access_token
88
+ queryParameters:
89
+ filter:
90
+ description: What to filter
91
+ type: string
92
+ responses:
93
+ 200:
94
+ post:
95
+ body:
96
+ application/json:
97
+ application/x-www-form-urlencoded:
98
+ formParameters:
99
+ name:
100
+ description: The name of the resource to create
101
+ type: string
102
+ example: Comment
103
+ description:
104
+ description: A description of the resource to create
105
+ type: string
106
+ example: User-generated content pertinent to the associated blog post
107
+ multipart/form-data:
108
+ formParameters:
109
+ name:
110
+ description: The name of the resource to create
111
+ type: string
112
+ example: Comment
113
+ description:
114
+ description: A description of the resource to create
115
+ type: string
116
+ example: User-generated content pertinent to the associated blog post
117
+ responses:
118
+ 200:
119
+ 201:
120
+ 203:
121
+
122
+ /another/resource:
123
+ displayName: Cats
124
+ type: longCollectionName
125
+ is: [secured, catpictures, anotherTrait, andAnotherTrait]
126
+ connect: !!null
127
+ head:
128
+ responses:
129
+ 200:
130
+ 201:
131
+ 203:
132
+ get:
133
+ queryParameters:
134
+ chunk:
135
+ displayName: page
136
+ description: Which page to display
137
+ type: integer
138
+ example: 1
139
+ minimum: 1
140
+ maximum: 100
141
+ required: true
142
+ order:
143
+ description: The sort order of resources
144
+ type: string
145
+ enum: ["oldest", "newest"]
146
+ example: oldest
147
+ minLength: 5
148
+ maxLength: 7
149
+ default: newest
150
+ query:
151
+ description: A query parameter
152
+ repeat: true
153
+
154
+ /resource-with-headers:
155
+ displayName: Resource With headers
156
+ get:
157
+ headers:
158
+ x-custom-header:
159
+ displayName: Custom header
160
+ description: This header is used to send data that...
161
+ type: string
162
+ pattern: ^\w+$
163
+ x-p-{*}:
164
+ displayName: Parameterized header
165
+
166
+ /secured-resource:
167
+ displayName: SO SECURE
168
+ get:
169
+ securedBy: [basic]
170
+ /resource-with-method-level-traits:
171
+ displayName: First One
172
+ is: [secured]
173
+ get:
174
+ is: [unsecured, catpictures, anotherTrait, andAnotherTrait, andYetAnotherTrait, aFinalTrait, {someParameterizedTrait: { someParameterName: someParameterValue }}]
175
+ description: get the first one
176
+ /resource-with-form-and-multipart-form-parameters:
177
+ get:
178
+ queryParameters:
179
+ some_query_param:
180
+ displayName: Some Query Param
181
+ description: Your value for some thing.
182
+ type: string
183
+ required: true
184
+ example: "my value"
185
+ body:
186
+ application/json:
187
+ example: |
188
+ {
189
+ "api_key": "c4f820f0420a013ea143230c290fbf99",
190
+ ...
191
+ }
192
+ application/x-www-form-urlencoded:
193
+ formParameters:
194
+ api_key:
195
+ displayName: API Key
196
+ description: Your license key for the application. Please contact developer@nzpost.co.nz for a license key
197
+ type: string
198
+ required: true
199
+ example: "c4f820f0420a013ea143230c290fbf99"
200
+ multipart/form-data:
201
+ formParameters:
202
+ api_key:
203
+ displayName: API Key
204
+ description: Your license key for the application. Please contact developer@nzpost.co.nz for a license key
205
+ type: string
206
+ required: true
207
+ example: "c4f820f0420a013ea143230c290fbf99"
208
+ /resource-with-repeatable-params:
209
+ post:
210
+ queryParameters:
211
+ someParam:
212
+ repeat: true
213
+ notRepeatable:
214
+ body:
215
+ application/x-www-form-urlencoded:
216
+ formParameters:
217
+ someFormParam:
218
+ repeat: true
219
+ multipart/form-data:
220
+ formParameters:
221
+ someMultipartFormParam:
222
+ type: file
223
+ repeat: true
224
+ someMultipartFormParamWithMultipleTypes:
225
+ - type: file
226
+ - type: string
227
+ repeat: true
228
+ headers:
229
+ someHeader:
230
+ repeat: true
231
+ x-meta-{*}:
232
+ repeat: true
233
+