@@ -3,33 +3,26 @@ from os.path import exists
33from pathlib import Path
44from sys.ffi import external_call
55from lightbug_http import HTTPRequest, HTTPResponse, Server, NotFound
6- from external. emberjson import JSON , Array, Object, Value, to_string
6+ from emberjson import JSON , Array, Object, Value, to_string
77from lightbug_api.openapi.generate import OpenAPIGenerator
88from lightbug_api.routing import Router
99from lightbug_api.logger import logger
1010from lightbug_api.docs import DocsApp
1111
1212@value
13- struct App :
13+ struct App[docs_enabled: Bool = False ] :
1414 var router : Router
1515 var lightbug_dir : Path
16- var docs_enabled : Bool
1716
1817 fn __init__ (inout self ) raises :
1918 self .router = Router()
2019 self .lightbug_dir = Path()
21- self .docs_enabled = True
22-
23- fn __init__ (inout self , docs_enabled : Bool) raises :
24- self .router = Router()
25- self .lightbug_dir = Path()
26- self .docs_enabled = docs_enabled
2720
2821 fn set_lightbug_dir (mut self , lightbug_dir : Path):
2922 self .lightbug_dir = lightbug_dir
3023
3124 fn func (mut self , req : HTTPRequest) raises -> HTTPResponse:
32- if self . docs_enabled and req.uri.path == " /docs" and req.method == " GET" :
25+ if docs_enabled and req.uri.path == " /docs" and req.method == " GET" :
3326 var openapi_spec = self .generate_openapi_spec()
3427 var docs = DocsApp(to_string(openapi_spec))
3528 return docs.func(req)
@@ -98,7 +91,7 @@ struct App:
9891 return openapi_spec
9992
10093 fn start_server (mut self , address : StringLiteral = " 0.0.0.0:8080" ) raises :
101- if self . docs_enabled:
94+ if docs_enabled:
10295 logger.info(" API Docs ready at: " + " http://" + String(address) + " /docs" )
10396 self .update_temporary_files()
10497 var server = Server()
0 commit comments