Skip to content

Commit 15e91e5

Browse files
authored
Merge pull request #20 from community-of-python/vrslev-patch-1
Disable debug and reload & enable offline docs by default
2 parents 0a5693a + cda71a8 commit 15e91e5

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ from microbootstrap import LitestarSettings
9797

9898
class YourSettings(LitestarSettings):
9999
# General settings
100-
service_debug: bool = False
101100
service_name: str = "my-awesome-service"
102101

103102
# Sentry settings
@@ -140,7 +139,6 @@ Example:
140139

141140
```python
142141
class YourSettings(BaseServiceSettings):
143-
service_debug: bool = True
144142
service_name: str = "micro-service"
145143

146144
your_awesome_parameter: str = "really awesome"
@@ -171,7 +169,6 @@ from microbootstrap.settings import BaseServiceSettings
171169

172170

173171
class ServiceSettings(BaseServiceSettings):
174-
service_debug: bool = True
175172
service_environment: str | None = None
176173
service_name: str = "micro-service"
177174
service_description: str = "Micro service description"
@@ -325,7 +322,7 @@ These settings are subsequently passed to [opentelemetry](https://opentelemetry.
325322
<b>microbootstrap</b> provides in-memory JSON logging through the use of [structlog](https://pypi.org/project/structlog/).
326323
For more information on in-memory logging, refer to [MemoryHandler](https://docs.python.org/3/library/logging.handlers.html#memoryhandler).
327324

328-
To utilize this feature, your application must be in non-debug mode, meaning `service_debug` should be set to `False`.
325+
To utilize this feature, your application must be in non-debug mode, meaning `service_debug` should be set to `False`, which is the default.
329326

330327
```python
331328
import logging

microbootstrap/instruments/swagger_instrument.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SwaggerConfig(BaseInstrumentConfig):
1414
service_static_path: str = "/static"
1515

1616
swagger_path: str = "/docs"
17-
swagger_offline_docs: bool = False
17+
swagger_offline_docs: bool = True
1818
swagger_extra_params: dict[str, typing.Any] = pydantic.Field(default_factory=dict)
1919

2020

microbootstrap/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
class BaseServiceSettings(
2626
pydantic_settings.BaseSettings,
2727
):
28-
service_debug: bool = True
28+
service_debug: bool = False
2929
service_environment: str | None = None
3030
service_name: str = pydantic.Field(
3131
"micro-service", validation_alias=pydantic.AliasChoices("SERVICE_NAME", f"{ENV_PREFIX}SERVICE_NAME")
@@ -38,7 +38,7 @@ class BaseServiceSettings(
3838

3939
server_host: str = "0.0.0.0" # noqa: S104
4040
server_port: int = 8000
41-
server_reload: bool = True
41+
server_reload: bool = False
4242
server_workers_count: int = 1
4343

4444
model_config = pydantic_settings.SettingsConfigDict(

tests/instruments/test_swagger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def test_swagger_teardown(
3939

4040

4141
def test_litestar_swagger_bootstrap_online_docs(minimal_swagger_config: SwaggerConfig) -> None:
42+
minimal_swagger_config.swagger_offline_docs = False
4243
swagger_instrument: typing.Final = LitestarSwaggerInstrument(minimal_swagger_config)
4344

4445
swagger_instrument.bootstrap()
@@ -52,7 +53,6 @@ def test_litestar_swagger_bootstrap_online_docs(minimal_swagger_config: SwaggerC
5253

5354

5455
def test_litestar_swagger_bootstrap_offline_docs(minimal_swagger_config: SwaggerConfig) -> None:
55-
minimal_swagger_config.swagger_offline_docs = True
5656
swagger_instrument: typing.Final = LitestarSwaggerInstrument(minimal_swagger_config)
5757

5858
swagger_instrument.bootstrap()
@@ -72,6 +72,7 @@ async def test_litestar_swagger_bootstrap_working_online_docs(
7272
minimal_swagger_config: SwaggerConfig,
7373
) -> None:
7474
minimal_swagger_config.swagger_path = "/my-docs-path"
75+
minimal_swagger_config.swagger_offline_docs = False
7576
swagger_instrument: typing.Final = LitestarSwaggerInstrument(minimal_swagger_config)
7677

7778
swagger_instrument.bootstrap()
@@ -88,7 +89,6 @@ async def test_litestar_swagger_bootstrap_working_offline_docs(
8889
minimal_swagger_config: SwaggerConfig,
8990
) -> None:
9091
minimal_swagger_config.service_static_path = "/my-static-path"
91-
minimal_swagger_config.swagger_offline_docs = True
9292
swagger_instrument: typing.Final = LitestarSwaggerInstrument(minimal_swagger_config)
9393

9494
swagger_instrument.bootstrap()
@@ -116,6 +116,7 @@ async def test_fastapi_swagger_bootstrap_working_online_docs(
116116
minimal_swagger_config: SwaggerConfig,
117117
) -> None:
118118
minimal_swagger_config.swagger_path = "/my-docs-path"
119+
minimal_swagger_config.swagger_offline_docs = False
119120
swagger_instrument: typing.Final = FastApiSwaggerInstrument(minimal_swagger_config)
120121

121122
swagger_instrument.bootstrap()
@@ -132,7 +133,6 @@ async def test_fastapi_swagger_bootstrap_working_offline_docs(
132133
minimal_swagger_config: SwaggerConfig,
133134
) -> None:
134135
minimal_swagger_config.service_static_path = "/my-static-path"
135-
minimal_swagger_config.swagger_offline_docs = True
136136
swagger_instrument: typing.Final = FastApiSwaggerInstrument(minimal_swagger_config)
137137
fastapi_application = fastapi.FastAPI(
138138
**swagger_instrument.bootstrap_before(),

0 commit comments

Comments
 (0)