Configuration¶
Main Configuration¶
You are able to turn on/off the validation against the RAML specification within the config.ini
file:
[main]
validation = False # defaults to True if not set
This configuration is ignored when using the validate function directly (but other configurations are not ignored).
Supported Custom Validation Configuration¶
In support of the RAML spec, ramlfications
will automatically support
the following:
RAML Versions¶
raml_versions
0.8
HTTP Methods¶
http_methods
GET
, POST
, PUT
, DELETE
, PATCH
, HEAD
, OPTIONS
, TRACE
, CONNECT
Authentication Schemes¶
auth_schemes
HTTP Response Codes¶
resp_codes
BaseHTTPServer
100
, 101
,200
, 201
, 202
, 203
, 204
, 205
, 206
,300
, 301
, 302
, 303
, 304
, 305
, 307
,400
, 401
, 402
, 403
, 404
, 405
, 406
, 407
, 408
, 409
, 410
, 411
, 412
, 413
, 414
, 415
, 416
, 417
,500
, 501
, 502
, 503
, 504
, 505
Protocols¶
protocols
HTTP
, HTTPS
MIME Media Types¶
media_types
application\/[A-Za-z.-0-1]*+?(json|xml)
User-specified¶
You may define additional values beyond what ramlfications
already supports above.
To do so, create your own ini
file with a [custom]
section.
Then add the attributes defined above that you want to support. You can only add support to the configuration values explained above.
Warning
Additionally supported values defined in your configuration will only add to the values
that ramlfications
will validate against; it will not overwrite values that the
ramlfications
supports as defined in the RAML spec.
An example config.ini
file:
[custom]
raml_versions = 0.9, 1.0
http_methods = foo, bar
auth_schemes = oauth_3_0, my_auth
media_types = application/vnd.foobar.v2
protocols = FTP
resp_codes = 429, 440
Usage¶
To use your configuration from within Python:
>>> from ramlfications import parse, validate
>>> RAML_FILE = "path/to/api.raml"
>>> CONFIG_FILE = "path/to/api.ini"
>>> api = parse(RAML_FILE, CONFIG_FILE)
>>> validate(RAML_FILE, CONFIG_FILE)
>>>
To use via the command line:
$ ramlfications validate --config path/to/api.ini path/to/api.raml
$ ramlfications tree --config path/to/api.ini path/to/api.raml