Skip to content

Commit

Permalink
🔖 chore(spec.py): add publish_apidoc flag to SpecTree constructor
Browse files Browse the repository at this point in the history
The `publish_apidoc` flag is added to the `SpecTree` constructor to allow users to disable publishing of the API documentation. If the flag is set to `False`, the `register_route` method will not be called, and the `backend.app` attribute will be set to the `app` attribute.
  • Loading branch information
AndreasBBS committed May 14, 2023
1 parent 0508b70 commit f0ea3c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion spectree/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(
validation_error_model: Optional[ModelType] = None,
naming_strategy: NamingStrategy = get_model_key,
nested_naming_strategy: NestedNamingStrategy = get_nested_key,
publish_apidoc: bool = True,
**kwargs: Any,
):
self.naming_strategy = naming_strategy
Expand All @@ -77,6 +78,7 @@ def __init__(
self.validation_error_model = validation_error_model or ValidationError
self.config: Configuration = Configuration.parse_obj(kwargs)
self.backend_name = backend_name
self.publish_apidoc = publish_apidoc
if backend:
self.backend = backend(self)
else:
Expand All @@ -95,7 +97,10 @@ def register(self, app: Any):
init step.
"""
self.app = app
self.backend.register_route(self.app)
if self.publish_apidoc:
self.backend.register_route(self.app)
else:
self.backend.app = self.app

@property
def spec(self):
Expand Down

0 comments on commit f0ea3c8

Please sign in to comment.