@@ -105,43 +105,14 @@ async def custom_swagger_ui(request: Request) -> HTMLResponse:
105105
106106
107107@app .get ("/api" , include_in_schema = True )
108- @app .get ("/api/" , include_in_schema = False )
109108def openapi_json_get () -> JSONResponse :
110109 """Return the OpenAPI schema (openapi.json)."""
111110 return JSONResponse (app .openapi ())
112111
113112
114- @app .post ("/api" , include_in_schema = False )
115- @app .post ("/api/" , include_in_schema = False )
116- def openapi_json_post () -> JSONResponse :
117- """Return the OpenAPI schema (openapi.json)."""
118- return JSONResponse (app .openapi ())
119-
120-
121- @app .put ("/api" , include_in_schema = False )
122- @app .put ("/api/" , include_in_schema = False )
123- def openapi_json_put () -> JSONResponse :
124- """Return the OpenAPI schema (openapi.json)."""
125- return JSONResponse (app .openapi ())
126-
127-
128- @app .delete ("/api" , include_in_schema = False )
129- @app .delete ("/api/" , include_in_schema = False )
130- def openapi_json_delete () -> JSONResponse :
131- """Return the OpenAPI schema (openapi.json)."""
132- return JSONResponse (app .openapi ())
133-
134-
135- @app .options ("/api" , include_in_schema = False )
136- @app .options ("/api/" , include_in_schema = False )
137- def openapi_json_options () -> JSONResponse :
138- """Return the OpenAPI schema (openapi.json)."""
139- return JSONResponse (app .openapi ())
140-
141-
142- @app .head ("/api" , include_in_schema = False )
143- @app .head ("/api/" , include_in_schema = False )
144- def openapi_json_head () -> JSONResponse :
113+ @app .api_route ("/api" , methods = ["POST" , "PUT" , "DELETE" , "OPTIONS" , "HEAD" ], include_in_schema = False )
114+ @app .api_route ("/api/" , methods = ["GET" , "POST" , "PUT" , "DELETE" , "OPTIONS" , "HEAD" ], include_in_schema = False )
115+ def openapi_json () -> JSONResponse :
145116 """Return the OpenAPI schema (openapi.json)."""
146117 return JSONResponse (app .openapi ())
147118
0 commit comments