raml_ruby 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +71 -0
  7. data/Rakefile +1 -0
  8. data/fixtures/include_1.raml +7 -0
  9. data/fixtures/schemas/canonicalSchemas.raml +3 -0
  10. data/fixtures/schemas/filesystem/file.json +1 -0
  11. data/fixtures/schemas/filesystem/files.json +1 -0
  12. data/fixtures/schemas/filesystem/fileupdate.json +1 -0
  13. data/fixtures/schemas/filesystem/relative/test.json +1 -0
  14. data/lib/raml.rb +104 -0
  15. data/lib/raml/exceptions.rb +27 -0
  16. data/lib/raml/mixin/bodies.rb +32 -0
  17. data/lib/raml/mixin/documentable.rb +32 -0
  18. data/lib/raml/mixin/global.rb +20 -0
  19. data/lib/raml/mixin/headers.rb +22 -0
  20. data/lib/raml/mixin/merge.rb +24 -0
  21. data/lib/raml/mixin/parent.rb +54 -0
  22. data/lib/raml/mixin/validation.rb +49 -0
  23. data/lib/raml/node.rb +219 -0
  24. data/lib/raml/node/abstract_method.rb +61 -0
  25. data/lib/raml/node/abstract_resource.rb +165 -0
  26. data/lib/raml/node/abstract_resource_circular.rb +5 -0
  27. data/lib/raml/node/body.rb +94 -0
  28. data/lib/raml/node/documentation.rb +28 -0
  29. data/lib/raml/node/header.rb +4 -0
  30. data/lib/raml/node/method.rb +106 -0
  31. data/lib/raml/node/parameter/abstract_parameter.rb +251 -0
  32. data/lib/raml/node/parameter/base_uri_parameter.rb +6 -0
  33. data/lib/raml/node/parameter/form_parameter.rb +6 -0
  34. data/lib/raml/node/parameter/query_parameter.rb +6 -0
  35. data/lib/raml/node/parameter/uri_parameter.rb +7 -0
  36. data/lib/raml/node/parametized_reference.rb +15 -0
  37. data/lib/raml/node/reference.rb +4 -0
  38. data/lib/raml/node/resource.rb +26 -0
  39. data/lib/raml/node/resource_type.rb +20 -0
  40. data/lib/raml/node/resource_type_reference.rb +5 -0
  41. data/lib/raml/node/response.rb +32 -0
  42. data/lib/raml/node/root.rb +246 -0
  43. data/lib/raml/node/schema.rb +41 -0
  44. data/lib/raml/node/schema_reference.rb +5 -0
  45. data/lib/raml/node/template.rb +55 -0
  46. data/lib/raml/node/trait.rb +18 -0
  47. data/lib/raml/node/trait_reference.rb +5 -0
  48. data/lib/raml/parser.rb +57 -0
  49. data/lib/raml/parser/include.rb +25 -0
  50. data/lib/raml/patch/hash.rb +6 -0
  51. data/lib/raml/patch/module.rb +12 -0
  52. data/lib/raml/version.rb +3 -0
  53. data/raml_ruby.gemspec +35 -0
  54. data/raml_spec_reqs.md +276 -0
  55. data/templates/abstract_parameter.slim +68 -0
  56. data/templates/body.slim +15 -0
  57. data/templates/collapse.slim +10 -0
  58. data/templates/documentation.slim +2 -0
  59. data/templates/method.slim +38 -0
  60. data/templates/resource.slim +33 -0
  61. data/templates/response.slim +13 -0
  62. data/templates/root.slim +39 -0
  63. data/templates/style.sass +119 -0
  64. data/test/apis/box-api.raml +4224 -0
  65. data/test/apis/instagram-api.raml +3378 -0
  66. data/test/apis/stripe-api.raml +12227 -0
  67. data/test/apis/twilio-rest-api.raml +6618 -0
  68. data/test/apis/twitter-rest-api.raml +34284 -0
  69. data/test/raml/body_spec.rb +268 -0
  70. data/test/raml/documentation_spec.rb +49 -0
  71. data/test/raml/header_spec.rb +17 -0
  72. data/test/raml/include_spec.rb +40 -0
  73. data/test/raml/method_spec.rb +701 -0
  74. data/test/raml/parameter/abstract_parameter_spec.rb +564 -0
  75. data/test/raml/parameter/form_parameter_spec.rb +17 -0
  76. data/test/raml/parameter/query_parameter_spec.rb +33 -0
  77. data/test/raml/parameter/uri_parameter_spec.rb +44 -0
  78. data/test/raml/parser_spec.rb +53 -0
  79. data/test/raml/raml_spec.rb +32 -0
  80. data/test/raml/resource_spec.rb +440 -0
  81. data/test/raml/resource_type_spec.rb +51 -0
  82. data/test/raml/response_spec.rb +251 -0
  83. data/test/raml/root_spec.rb +655 -0
  84. data/test/raml/schema_spec.rb +110 -0
  85. data/test/raml/spec_helper.rb +11 -0
  86. data/test/raml/template_spec.rb +98 -0
  87. data/test/raml/trait_spec.rb +31 -0
  88. metadata +337 -0
@@ -0,0 +1,18 @@
1
+ module Raml
2
+ class Trait < Template
3
+ class Instance < AbstractMethod
4
+ inherit_class_attributes
5
+
6
+ # @!attribute [rw] usage
7
+ # @return [String,nil] how the trait should be used.
8
+ scalar_property :usage
9
+ end
10
+
11
+ # Instantiate a new trait with the given parameters.
12
+ # @param params [Hash] the parameters to interpolate in the trait.
13
+ # @return [Raml::Trait::Instance] the instantiated trait.
14
+ def instantiate(params)
15
+ Instance.new( *interpolate(params), @parent )
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Raml
2
+ # A reference to a trait defined in the root node.
3
+ class TraitReference < ParametizedReference
4
+ end
5
+ end
@@ -0,0 +1,57 @@
1
+ require 'yaml'
2
+
3
+ module Raml
4
+ # @private
5
+ class Parser
6
+ class << self
7
+ def parse(data, file_dir=Dir.getwd)
8
+ register_include_tag
9
+
10
+ data = YAML.load data
11
+ expand_includes data, file_dir
12
+
13
+ Root.new data
14
+ end
15
+
16
+ private
17
+
18
+ def register_include_tag
19
+ YAML.add_tag '!include', Raml::Parser::Include
20
+ end
21
+
22
+ def expand_includes(val, cwd)
23
+ case val
24
+ when Hash
25
+ val.merge!(val, &expand_includes_transform(cwd))
26
+ when Array
27
+ val.map!(&expand_includes_transform(cwd))
28
+ end
29
+ end
30
+
31
+ def expand_includes_transform(cwd)
32
+ proc do |arg1, arg2|
33
+ val = arg2.nil? ? arg1 : arg2
34
+ child_wd = cwd
35
+
36
+ if val.is_a? Raml::Parser::Include
37
+ child_wd = expand_includes_working_dir cwd, val.path
38
+ val = val.content cwd
39
+ end
40
+
41
+ expand_includes val, child_wd
42
+
43
+ val
44
+ end
45
+ end
46
+
47
+ def expand_includes_working_dir(current_wd, include_pathname)
48
+ include_path = File.dirname include_pathname
49
+ if include_path.start_with? '/'
50
+ include_path
51
+ else
52
+ "#{current_wd}/#{include_path}"
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,25 @@
1
+ # @private
2
+ class Raml::Parser
3
+ class Include
4
+ attr_reader :path
5
+
6
+ def init_with(coder)
7
+ @path = coder.scalar
8
+ end
9
+
10
+ def content(cwd)
11
+ pathname = @path.start_with?('/') ? @path : "#{cwd}/#{@path}"
12
+ @content = File.open(pathname).read
13
+ @content = YAML.load @content if is_yaml?
14
+ @content
15
+ rescue => e
16
+ raise Raml::CantIncludeFile, e
17
+ end
18
+
19
+ private
20
+
21
+ def is_yaml?
22
+ [ 'yaml', 'yml', 'raml' ].include? @path.split('.').last.downcase
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,6 @@
1
+ # @private
2
+ class Hash
3
+ def map!(&block)
4
+ replace Hash[ map(&block) ]
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ # @private
2
+ class Module
3
+ private
4
+ def attr_reader_default(attribute, default)
5
+ alias_method("#{attribute}_orig".to_sym, attribute) unless method_defined? "#{attribute}_orig"
6
+
7
+ define_method attribute do
8
+ val = send("#{attribute}_orig".to_sym)
9
+ val.nil? ? default : val
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Raml
2
+ VERSION = "0.1.1"
3
+ end
data/raml_ruby.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'raml/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "raml_ruby"
8
+ spec.version = Raml::VERSION
9
+ spec.authors = ["Kirill Gorin"]
10
+ spec.email = ["me@kgor.in"]
11
+ spec.description = %q{Implementation of RAML parser in Ruby.}
12
+ spec.summary = %q{raml_ruby is implementation of RAML parser in Ruby.}
13
+ spec.homepage = "https://github.com/coub/raml_ruby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'activesupport', '~> 4.1'
22
+ spec.add_dependency 'json-schema' , '~> 2.2'
23
+ spec.add_dependency 'kramdown' , '~> 1.4'
24
+ spec.add_dependency 'rouge' , '~> 1.7'
25
+ spec.add_dependency 'sass' , '~> 3.4'
26
+ spec.add_dependency 'slim' , '~> 2.0'
27
+ spec.add_dependency 'uri_template' , '~> 0.7'
28
+
29
+ spec.add_development_dependency 'bundler', "~> 1.3"
30
+ spec.add_development_dependency 'rake' , '~> 10.0'
31
+ spec.add_development_dependency 'rspec' , '~> 3.0'
32
+ spec.add_development_dependency 'rr' , '~> 1.1'
33
+ spec.add_development_dependency "pry" , '~> 0.10'
34
+ spec.add_development_dependency "yard" , '~> 0.8'
35
+ end
data/raml_spec_reqs.md ADDED
@@ -0,0 +1,276 @@
1
+ # Markup Language
2
+ - [x] The RAML version MUST be the first line of the RAML document.
3
+ - [x] RAML parsers MUST interpret all other YAML-commented lines as comments.
4
+ - [x] In RAML, all values MUST be interpreted in a case-sensitive manner.
5
+
6
+ ## Includes
7
+ - [x] All RAML parsers MUST support the include tag, which enables including RAML and YAML and regular text files.
8
+ - [x] When RAML or YAML files are included, RAML parsers MUST not only read the content, but parse it and add the content to the declaring structure as if the content were declared inline.
9
+ - [x] If a relative path is used for the included file, the path is interpreted relative to the location of the original (including) file.
10
+ - [ ] If the original file is fetched as an HTTP resource, the included file SHOULD be fetched over HTTP.
11
+ - [ ] If the included file has one of the following media types:
12
+ - application/raml+yaml
13
+ - text/yaml
14
+ - text/x-yaml
15
+ - application/yaml
16
+ - application/x-yaml
17
+ RAML parsers MUST parse the content the file as RAML content and append the parsed structures to the RAML document's node.
18
+ - [x] If the included file has a .raml or .yml or .yaml extension, RAML parsers MUST parse the content the file as RAML content and append the parsed structures to the RAML document's node.
19
+
20
+
21
+ # Named Parameters
22
+
23
+ ### type
24
+ - [x] If type is not specified, it defaults to string.
25
+ - [x] Valid types are: string, number, integer, date, boolean, file.
26
+
27
+ ### enum
28
+ - [x] Optional.
29
+ - [x] Applicable only for parameters of type string.
30
+ - [x] MUST be an array.
31
+
32
+ ### pattern
33
+ - [x] Optional.
34
+ - [x] Applicable only for parameters of type string.
35
+ - [x] The pattern attribute is a regular expression.
36
+ - [x] Regular expressions MUST follow the regular expression specification from ECMA 262/Perl 5.
37
+ - [x] The pattern MAY be enclosed in double quotes for readability and clarity.
38
+
39
+ ### minLength
40
+ - [x] Optional.
41
+ - [x] Applicable only for parameters of type string.
42
+
43
+ ### maxLength
44
+ - [x] Optional.
45
+ - [x] Applicable only for parameters of type string.
46
+
47
+ ### minimal
48
+ - [x] Optional.
49
+ - [x] Applicable only for parameters of type number or integer.
50
+
51
+ ### maximum
52
+ - [x] Optional.
53
+ - [x] Applicable only for parameters of type number or integer.
54
+
55
+ ### example
56
+ - [x] Optional.
57
+
58
+ ### repeat
59
+ - [x] Optional.
60
+ - [x] The default value is 'false'.
61
+
62
+ ### required
63
+ - [x] Optional except as otherwise noted.
64
+ - [x] In general, parameters are optional unless the required attribute is included and its value set to 'true'.
65
+ - [x] For a URI parameter, the required attribute MAY be omitted, but its default value is 'true'.
66
+
67
+ ### default
68
+ - [x] Optional.
69
+
70
+ ## Named Parameters With Multiple Types
71
+ - [x] To denote that a named parameter can have multiple types, the value of the named parameter property MAY be an array of mappings, each of which has the attributes described in this document.
72
+
73
+
74
+ ## Basic Information
75
+ ###Root Section
76
+ - [x] RAML-documented API definition properties MAY appear in any order.
77
+
78
+ ### API Title
79
+ - [x] Required.
80
+ - [x] The title property is a short plain text description of the RESTful API.
81
+
82
+ ### API Version
83
+ - [x] Optional.
84
+
85
+ ### Base URI and baseUriParameters
86
+ - [ ] Optional during development.
87
+ - [x] Required after implementation.
88
+ - [x] The baseUri property's value MUST conform to the URI specification [RFC2396] or a Level 1 Template URI [RFC6570].
89
+ - [ ] If a URI template variable in the base URI is not explicitly described in a baseUriParameters property, and is not specified in a resource-level uriParameters property, it MUST still be treated as a base URI parameter with defaults as specified in the Named Parameters section of this specification. Its type is "string", it is required, and its displayName is its name (i.e. without the surrounding curly brackets [{] and [}]).
90
+
91
+ ### Protocols
92
+ - [x] Optional.
93
+ - [x] The protocols property MUST be an array of strings, of values "HTTP" and/or "HTTPS".
94
+
95
+ ### Default Media Type
96
+ - [x] Optional.
97
+ - [x] The media types returned by API responses, and expected from API requests that accept a body, MAY be defaulted by specifying the mediaType property.
98
+
99
+ ### Schemas
100
+ - [x] Optional.
101
+ - [x] The value of the schemas property is an array of maps; in each map, the keys are the schema name, and the values are schema definitions.
102
+ - [x] The schema definitions MAY be included inline or by using the RAML !include user-defined data type.
103
+
104
+ ### Base URI Parameters
105
+ - [x] Optional.
106
+ - [x] The baseUriParameters property MUST be a map in which each key MUST be the name of the URI parameter as defined in the baseUri property.
107
+ - [x] The uriParameters CANNOT contain a key named version because it is a reserved URI parameter name.
108
+
109
+ ### User Documentation
110
+ - [x] Optional.
111
+ - [x] Documentation-generators MUST include all the sections in an API definition's documentation property in the documentation output.
112
+ - [x] And they MUST preserve the order in which the documentation is declared.
113
+ - [x] The documentation property MUST be an array of documents.
114
+ - [x] Each document MUST contain title and content attributes, both of which are REQUIRED.
115
+ - [x] If the documentation property is specified, it MUST include at least one document.
116
+ - [x] Documentation-generators MUST process the content field as if it was defined using Markdown.
117
+ - [x] The documentation property MAY be included inline, as described above, or by using the RAML !include user-defined data type to reference external content.
118
+
119
+ ### Resources and Nested Resources
120
+ - [x] Resources are identified by their relative URI, which MUST begin with a slash (/).
121
+ - [x] A resource defined as a root-level property is called a top-level resource. Its property's key is the resource's URI relative to the baseUri.
122
+ - [x] A resource defined as a child property of another resource is called a nested resource, and its property's key is its URI relative to its parent resource's URI.
123
+ - [x] Every property whose key begins with a slash (/), and is either at the root of the API definition or is the child property of a resource property, is a resource property.
124
+
125
+ #### Display Name
126
+ - [x] The displayName key is OPTIONAL.
127
+ - [x] If the displayName attribute is not defined for a resource, documentation tools SHOULD refer to the resource by its property key (i.e. its relative URI, e.g., "/jobs"), which acts as the resource's name.
128
+
129
+ #### Description
130
+ - [x] Each resource, whether top-level or nested, MAY contain a description property that briefly describes the resource.
131
+
132
+ #### Template URIs and URI Parameters
133
+ - [x] A resource MAY contain a uriParameters property specifying the uriParameters in that resource's relative URI, as described in the Named Parameters section of this specification.
134
+
135
+ #### Base URI parameters
136
+ - [x] The baseUriParameters property MAY be used to override any or all parameters defined at the root level baseUriParameters property, as well as base URI parameters not specified at the root level.
137
+ - [x] In a resource structure of resources and nested resources with their methods, the most specific baseUriParameter fully overrides any baseUriParameter definition made before. In the following example the resource /user/{userId}/image overrides the definition made in /users.
138
+ - [x] The special baseUriParameter version is reserved.
139
+ - [ ] Processing applications MUST replace occurrences of {version} in any baseUri property values with the value of the root-level version property.
140
+ - [x] The {version} parameter, if used in a baseUri, is required.
141
+
142
+ #### Methods
143
+ - [x] A method MUST be one of the HTTP methods defined in the HTTP version 1.1 specification [RFC2616] and its extension, RFC5789 [RFC5789].
144
+
145
+ ##### Description
146
+ - [x] Each declared method MAY contain a description attribute that briefly describes what the method does to the resource.
147
+ - [x] The value of the description property MAY be formatted using Markdown [MARKDOWN].
148
+
149
+ ##### Headers
150
+ - [x] The headers property is a map in which the key is the name of the header, and the value is itself a map specifying the header attributes, according to the Named Parameters section.
151
+
152
+ ###### Example
153
+ - [x] Documentation generators MUST include content specified as example information for headers. This information is included in the API definition by using the example property.
154
+
155
+ ##### Protocols
156
+ - [ ] A method can override an API's protocols value for that single method by setting a different value for the fields.
157
+
158
+ ##### Query Strings
159
+ - [x] The queryParameters property is a map in which the key is the query parameter's name, and the value is itself a map specifying the query parameter's attributes, according to the Named Parameters section.
160
+ - [x] Query string queryParameters properties MAY include an example attribute.
161
+ - [ ] Documentation generators MUST use example attributes to generate example invocations.
162
+
163
+ ##### Body
164
+ - [x] Resources CAN have alternate representations.
165
+ - [x] A method's body is defined in the body property as a hashmap.
166
+ - [x] The key MUST be a valid media type.
167
+
168
+ ###### Web Forms
169
+ - [x] If the API's media type is either application/x-www-form-urlencoded or multipart/form-data, the formParameters property MUST specify the name-value pairs that the API is expecting.
170
+ - [x] The formParameters property is a map in which the key is the name of the web form parameter, and the value is itself a map the specifies the web form parameter's attributes, according to the Named Parameters section.
171
+
172
+ ###### Schema
173
+ - [x] The structure of a request or response body MAY be further specified by the schema property under the appropriate media type.
174
+ - [x] The schema key CANNOT be specified if a body's media type is application/x-www-form-urlencoded or multipart/form-data.
175
+ - [x] All parsers of RAML MUST be able to interpret JSON Schema [JSON_SCHEMA]
176
+ - [ ] All parsers of RAML MUST be able to interpret XML Schema [XML_SCHEMA].
177
+ - [x] Schema MAY be declared inline or in an external file.
178
+ - [x] Alternatively, the value of the schema field MAY be the name of a schema specified in the root-level schemas property.
179
+
180
+ ###### Example
181
+ - [x] Documentation generators MUST use body properties' example attributes to generate example invocations.
182
+
183
+ ##### Responses
184
+ - [x] Resource methods MAY have one or more responses.
185
+ - [x] Responses MAY be described using the description property.
186
+ - [x] And MAY include example attributes or schema properties
187
+ - [x] Responses MUST be a map of one or more HTTP status codes, where each status code itself is a map that describes that status code.
188
+ - [x] Each response MAY contain a body property, which conforms to the same structure as request body properties (see Body).
189
+ - [x] Responses that can return more than one response code MAY therefore have multiple bodies defined.
190
+ - [x] Responses MAY contain a description property that further clarifies why the response was emitted.
191
+
192
+ ###### Headers
193
+ - [x] The headers property is a map in which the key is the name of the header, and the value is itself a map specifying the header attributes, according to the Named Parameters section.
194
+ - [x] Documentation generators MUST include content specified as example information for headers.
195
+
196
+ ### Resource Types and Traits
197
+ - [x] Resources may specify the resource type from which they inherit using the type property.
198
+ - [x] The resource type may be defined inline as the value of the type property (directly or via an !include).
199
+ - [x] Or the value of the type property may be the name of a resource type defined within the root-level resourceTypes property.
200
+ - [x] Methods may specify one or more traits from which they inherit using the is property.
201
+ - [x] A resource may also use the is property to apply the list of traits to all its methods.
202
+ - [x] The value of the is property is an array of traits.
203
+ - [x] Each trait element in that array may be defined inline (directly or via an !include).
204
+ - [x] Or it may be the name of a trait defined within the root-level traits property.
205
+ - [x] Resource type definitions MUST NOT incorporate nested resources.
206
+
207
+ #### Declaration
208
+ - [x] The resourceTypes and traits properties are declared at the API definition's root level with the resourceTypes and traits property keys, respectively.
209
+ - [x] The value of each of these properties is an array of maps; in each map, the keys are resourceType or trait names, and the values are resourceType or trait definitions, respectively.
210
+
211
+ ##### Usage
212
+ - [x] The usage property of a resource type or trait is used to describe how the resource type or trait should be used.
213
+ - [ ] Documentation generators MUST convey this property as characteristics of the resource and method, respectively.
214
+ - [x] However, the resources and methods MUST NOT inherit the usage property: neither resources nor methods allow a property named usage.
215
+
216
+ ##### Parameters
217
+ - [x] In resource type definitions, there are two reserved parameter names: resourcePath and resourcePathName. The processing application MUST set the values of these reserved parameters to the inheriting resource's path (for example, "/users") and the part of the path following the rightmost "/" (for example, "users"), respectively.
218
+ - [ ] Processing applications MUST also omit the value of any mediaTypeExtension found in the resource's URI when setting resourcePath and resourcePathName.
219
+ - [x] In trait definitions, there is one reserved parameter name, methodName, in addition to the resourcePath and resourcePathName. The processing application MUST set the value of the methodName parameter to the inheriting method's name. The processing application MUST set the values of the resourcePath and resourcePathName parameters the same as in resource type definitions.
220
+ - [x] The !singularize function MUST act on the value of the parameter by a locale-specific singularization of its original value. The only locale supported by this version of RAML is United States English.
221
+ - [x] The !pluralize function MUST act on the value of the parameter by a locale-specific pluralization of its original value. The only locale supported by this version of RAML is United States English.
222
+ - [x] Parameters may not be used within !include tags, that is, within the location of the file to be included. This will be reconsidered for future versions of RAML
223
+
224
+ ##### Optional Properties
225
+ - [x] A resource type or trait definition MAY append a question mark ("?") suffix to the name of any non-scalar property that should not be applied if it doesn't already exist in the resource or method at the corresponding level.
226
+ - [x] Using the optional marker ("?") in a scalar property such as usage or displayName MUST be rejected from RAML parsers.
227
+
228
+ #### Applying Resource Types and Traits
229
+ - [x] To apply a resource type definition to a resource, so that the resource inherits the resource type's characteristics, the resource MUST be defined using the type attribute
230
+ - [x] The value of the type attribute MUST be either a) one and only one of the resource type keys (names) included in the resourceTypes declaration, or b) one and only one resource type definition map.
231
+ - [x] To apply a trait definition to a method, so that the method inherits the trait's characteristics, the method MUST be defined by using the is attribute.
232
+ - [x] The value of the is attribute MUST be an array of any number of elements, each of which MUST be a) one or more trait keys (names) included in the traits declaration, or b) one or more trait definition maps.
233
+ - [x] A trait may also be applied to a resource by using the is key, which is equivalent to applying the trait to all methods for that resource, whether declared explicitly in the resource definition or inherited from a resource type.
234
+
235
+ ## Security
236
+
237
+ ### Declaration
238
+ - [ ] The securitySchemes property is declared at the API's root level.
239
+
240
+ ##### Description
241
+ - [ ] The description attribute MAY be used to describe a securitySchemes property.
242
+
243
+ ##### Type
244
+ - [ ] The type attribute MAY be used to convey information about authentication flows and mechanisms to processing applications such as Documentation Generators and Client generators.
245
+ - [ ] Processing applications SHOULD provide handling for the following schemes:
246
+ - [ ] OAuth 1.0 The API's authentication requires using OAuth 1.0 as described in RFC5849 [RFC5849]
247
+ - [ ] OAuth 2.0 The API's authentication requires using OAuth 2.0 as described in RFC6749 [RFC6749]
248
+ - [ ] Basic Authentication The API's authentication relies on using Basic Access Authentication as described in RFC2617 [RFC2617]
249
+ - [ ] Digest Authentication The API's authentication relies on using Digest Access Authentication as described in RFC2617 [RFC2617]
250
+ - [ ] x-{other} The API's authentication relies in another authentication method.
251
+
252
+ ##### describedBy
253
+ - [ ] The describedBy attribute MAY be used to apply a trait-like structure to a security scheme mechanism so as to extend the mechanism, such as specifying response codes, HTTP headers or custom documentation.
254
+
255
+ ##### Settings
256
+ - [ ] The settings attribute MAY be used to provide security schema-specific information.
257
+ - [ ] The following lists describe the minimum set of properties which any processing application MUST provide and validate if it chooses to implement the Security Scheme type.
258
+ - [ ] OAuth 1.0
259
+ - [ ] requestTokenUri The URI of the Temporary Credential Request endpoint as defined in RFC5849 Section 2.1
260
+ - [ ] authorizationUri The URI of the Resource Owner Authorization endpoint as defined in RFC5849 Section 2.2
261
+ - [ ] tokenCredentialsUri The URI of the Token Request endpoint as defined in RFC5849 Section 2.3
262
+ - [ ] OAuth 2.0
263
+ - [ ] authorizationUri The URI of the Authorization Endpoint as defined in RFC6749 [RFC6748] Section 3.1
264
+ - [ ] accessTokenUri The URI of the Token Endpoint as defined in RFC6749 [RFC6748] Section 3.2
265
+ - [ ] authorizationGrants A list of the Authorization grants supported by the API As defined in RFC6749 [RFC6749] Sections 4.1, 4.2, 4.3 and 4.4, can be any of: code, token, owner or credentials.
266
+ - [ ] scopes A list of scopes supported by the API as defined in RFC6749 [RFC6749] Section 3.3
267
+
268
+ ### Usage: Applying a Security Scheme to an API
269
+ - [ ] To apply a securityScheme definition to every method in an API, the API MAY be defined using the securedBy attribute. This specifies that all methods in the API are protected using that security scheme.
270
+ - [ ] Applying a securityScheme definition to a method overrides whichever securityScheme has been defined at the root level.
271
+ - [ ] To indicate that the method is protected using a specific security scheme, the method MUST be defined by using the securedBy attribute.
272
+ - [ ] The value of the securedBy attribute MUST be a list of any of the security schemas defined in the securitySchema declaration.
273
+ - [ ] A securityScheme may also be applied to a resource by using the securedBy key, which is equivalent to applying the securityScheme to all methods that may be declared, explicitly or implicitly, by defining the resourceTypes or traits property for that resource.
274
+ - [ ] To indicate that the method may be called without applying any securityScheme, the method may be annotated with the null securityScheme.
275
+ - [ ] If the processing application supports custom properties, custom parameters can be provided to the security scheme at the moment of inclusion in a method.
276
+