Skip to content

Commit

Permalink
Resolves #73 - setting to disable api-doc views.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Nephin committed Feb 20, 2015
1 parent 0a44a58 commit c259561
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ A few relevant settings for your `Pyramid .ini file <http://docs.pylonsproject.o
pyramid_swagger.skip_validation = /(static)\\b
/(api-docs)\\b
# Enable/disable automatic /api-doc endpoints to serve the swagger
# schemas (true by default)
pyramid_swagger.enable_api_doc_views = true
Note that, equivalently, you can add these during webapp configuration:

.. code-block:: python
Expand All @@ -38,5 +42,6 @@ Note that, equivalently, you can add these during webapp configuration:
settings['pyramid_swagger.enable_response_validation'] = True
settings['pyramid_swagger.enable_swagger_spec_validation'] = True
settings['pyramid_swagger.skip_validation'] = ['/(static)\\b', '/(api-docs)\\b']
settings['pyramid_swagger.enable_api_doc_views' = True
config = Configurator(settings=settings)
config.include('pyramid_swagger')
6 changes: 5 additions & 1 deletion pyramid_swagger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ def includeme(config):
"pyramid_swagger.tween.validation_tween_factory",
under=pyramid.tweens.EXCVIEW
)
register_api_doc_endpoints(config)
if config.registry.settings.get(
'pyramid_swagger.enable_api_doc_views',
True
):
register_api_doc_endpoints(config)
13 changes: 13 additions & 0 deletions tests/includeme_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import mock

import pyramid_swagger


@mock.patch('pyramid_swagger.register_api_doc_endpoints')
def test_disable_api_doc_views(mock_register):
settings = {
'pyramid_swagger.enable_api_doc_views': False,
}
mock_config = mock.Mock(registry=mock.Mock(settings=settings))
pyramid_swagger.includeme(mock_config)
assert not mock_register.called

0 comments on commit c259561

Please sign in to comment.