|
| 1 | +Configuration |
| 2 | +============= |
| 3 | + |
| 4 | +.. _supported: |
| 5 | + |
| 6 | +Supported |
| 7 | +--------- |
| 8 | + |
| 9 | +In support of the `RAML spec`_, ``ramlfications`` will automatically support |
| 10 | +the following: |
| 11 | + |
| 12 | +RAML Versions |
| 13 | +^^^^^^^^^^^^^ |
| 14 | + |
| 15 | +| **Config variable**: ``raml_versions`` |
| 16 | +| **Config type**: list of strings |
| 17 | +| **Supported**: ``0.8`` |
| 18 | +| |
| 19 | +
|
| 20 | + |
| 21 | +HTTP Methods |
| 22 | +^^^^^^^^^^^^ |
| 23 | +| **Config variable**: ``http_methods`` |
| 24 | +| **Config type**: list of strings |
| 25 | +| **Supported**: ``GET``, ``POST``, ``PUT``, ``DELETE``, ``PATCH``, ``HEAD``, ``OPTIONS``, ``TRACE``, ``CONNECT`` |
| 26 | +| |
| 27 | +
|
| 28 | +Authentication Schemes |
| 29 | +^^^^^^^^^^^^^^^^^^^^^^ |
| 30 | + |
| 31 | +| **Config variable**: ``auth_schemes`` |
| 32 | +| **Config type**: list of strings |
| 33 | +| **Supported**: OAuth 1.0, OAuth 2.0, Basic Authentication, Digest Authentication |
| 34 | +| |
| 35 | +
|
| 36 | +HTTP Response Codes |
| 37 | +^^^^^^^^^^^^^^^^^^^ |
| 38 | + |
| 39 | +| **Config variable**: ``resp_codes`` |
| 40 | +| **Config type**: list of integers |
| 41 | +| **Supported**: From Python stdlib ``BaseHTTPServer`` |
| 42 | +| ``100``, ``101``, |
| 43 | +| ``200``, ``201``, ``202``, ``203``, ``204``, ``205``, ``206``, |
| 44 | +| ``300``, ``301``, ``302``, ``303``, ``304``, ``305``, ``307``, |
| 45 | +| ``400``, ``401``, ``402``, ``403``, ``404``, ``405``, ``406``, ``407``, ``408``, ``409``, ``410``, ``411``, ``412``, ``413``, ``414``, ``415``, ``416``, ``417``, |
| 46 | +| ``500``, ``501``, ``502``, ``503``, ``504``, ``505`` |
| 47 | +| |
| 48 | +
|
| 49 | +Protocols |
| 50 | +^^^^^^^^^ |
| 51 | + |
| 52 | +| **Config variable**: ``protocols`` |
| 53 | +| **Config type**: list of strings |
| 54 | +| **Supported**: ``HTTP``, ``HTTPS`` |
| 55 | +| |
| 56 | +
|
| 57 | +MIME Media Types |
| 58 | +^^^^^^^^^^^^^^^^ |
| 59 | + |
| 60 | +| **Config variable**: ``media_types`` |
| 61 | +| **Config type**: list of strings that fit the regex defined under `default media type`_: ``application\/[A-Za-z.-0-1]*+?(json|xml)`` |
| 62 | +| **Supported**: MIME media types that the package supports can be found on `GitHub`_ and is up to date as of the time of this release (|today|). |
| 63 | +| |
| 64 | +
|
| 65 | +.. note:: |
| 66 | + If you would like to update your own setup with the latest `IANA`_ supported MIME media types, refer to :doc:`usage`. |
| 67 | + |
| 68 | + |
| 69 | +User-specified |
| 70 | +-------------- |
| 71 | + |
| 72 | +You may define additional values beyond what ``ramlfications`` already supports above. |
| 73 | + |
| 74 | +To do so, create your own ``ini`` file with a ``[custom]`` section. |
| 75 | + |
| 76 | +Then add the attributes defined :ref:`above <supported>` that you want to support. |
| 77 | +You can **only** add support to the configuration values explained above. |
| 78 | + |
| 79 | +.. warning:: |
| 80 | + |
| 81 | + Additionally supported values defined in your configuration will only **add** to the values |
| 82 | + that ``ramlfications`` will validate against; it will **not** overwrite values that the |
| 83 | + ``ramlfications`` supports as defined in the `RAML spec`_. |
| 84 | + |
| 85 | +An example ``config.ini`` file:: |
| 86 | + |
| 87 | + [custom] |
| 88 | + raml_versions = 0.9, 1.0 |
| 89 | + http_methods = foo, bar |
| 90 | + auth_schemes = oauth_3_0, my_auth |
| 91 | + media_types = application/vnd.foobar.v2 |
| 92 | + protocols = FTP |
| 93 | + resp_codes = 429, 440 |
| 94 | + |
| 95 | + |
| 96 | +Usage |
| 97 | +^^^^^ |
| 98 | + |
| 99 | +To use your configuration from within Python: |
| 100 | + |
| 101 | +.. code-block:: python |
| 102 | +
|
| 103 | + >>> from ramlfications import parse, validate |
| 104 | + >>> RAML_FILE = "path/to/api.raml" |
| 105 | + >>> CONFIG_FILE = "path/to/api.ini" |
| 106 | + >>> api = parse(RAML_FILE, CONFIG_FILE) |
| 107 | + >>> validate(RAML_FILE, CONFIG_FILE) |
| 108 | + >>> |
| 109 | +
|
| 110 | +To use via the command line: |
| 111 | + |
| 112 | +.. code-block:: bash |
| 113 | +
|
| 114 | + $ ramlfications validate --config path/to/api.ini path/to/api.raml |
| 115 | + $ ramlfications tree --config path/to/api.ini path/to/api.raml |
| 116 | +
|
| 117 | +
|
| 118 | +.. _`RAML spec`: http://raml.org/spec.html |
| 119 | +.. _`default media type`: http://raml.org/spec.html#default-media-type |
| 120 | +.. _IANA: https://www.iana.org/assignments/media-types/media-types.xml |
| 121 | +.. _GitHub: https://github.com/spotify/ramlfications/blob/master/ramlfications/data/supported_mime_types.json |
0 commit comments