Skip to content

Commit fb6f2eb

Browse files
docs(api): expose OpenAPI (Swagger) specification for OpenCRE REST API (#709)
* docs(api): add initial OpenAPI specification * docs(api): add initial OpenAPI specification * docs(api): expose OpenAPI specification via REST endpoint
1 parent c07a3d9 commit fb6f2eb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

application/web/web_main.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,21 @@ def standards() -> Any:
378378
return standards
379379

380380

381+
@app.route("/rest/v1/openapi.yaml", methods=["GET"])
382+
def openapi_spec() -> Any:
383+
"""
384+
Serve the OpenAPI specification for the OpenCRE REST API.
385+
"""
386+
return send_from_directory(
387+
directory=os.path.join(
388+
os.path.dirname(os.path.realpath(__file__)),
389+
"../../docs/api",
390+
),
391+
path="openapi.yaml",
392+
mimetype="application/yaml",
393+
)
394+
395+
381396
@app.route("/rest/v1/text_search", methods=["GET"])
382397
def text_search() -> Any:
383398
"""

0 commit comments

Comments
 (0)