forked from NVIDIA/nv-ingest
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for including openapi docs in the documentation output
- Loading branch information
Showing
8 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ mkdocs-site-urls | |
sphinx | ||
sphinx-markdown-builder | ||
sphinx-rtd-theme | ||
sphinxcontrib-openapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
:caption: nv-ingest User Guide | ||
|
||
api_docs/index | ||
openapi_docs/index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
API Reference | ||
============= | ||
|
||
.. openapi:: openapi.json | ||
:encoding: utf-8 |
19 changes: 19 additions & 0 deletions
19
docs/sphinx_docs/source/user_guide/openapi_docs/openapi.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"openapi": "3.1.0", | ||
"info": { | ||
"title": "NV-Ingest Microservice", | ||
"description": "Service for ingesting heterogenous datatypes", | ||
"contact": { | ||
"name": "NVIDIA Corporation", | ||
"url": "https://nvidia.com/" | ||
}, | ||
"version": "0.1.0" | ||
}, | ||
"paths": {}, | ||
"tags": [ | ||
{ | ||
"name": "Health", | ||
"description": "Health checks" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. | ||
# All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# syntax=docker/dockerfile:1.3 | ||
|
||
# The easiest way to run this script without having to install nv-ingest is adjust | ||
# your PYTHONPATH to include the NV_INGEST_REPO_ROOT/src directory like so ... | ||
# This script is intended to only be ran from NV_INGEST_REPO_ROOT | ||
# PYTHONPATH=$(pwd)/src:$(pwd)/client/src scripts/generated_openapi_docs.py | ||
|
||
import json | ||
import os | ||
from nv_ingest.main import app | ||
|
||
# Define output directory and file | ||
OUTPUT_DIR = "./docs/sphinx_docs/source/user_guide/openapi_docs" | ||
OUTPUT_FILE = os.path.join(OUTPUT_DIR, "openapi.json") | ||
|
||
# Ensure the output directory exists | ||
os.makedirs(OUTPUT_DIR, exist_ok=True) | ||
|
||
# Generate OpenAPI schema | ||
openapi_schema = app.openapi() | ||
|
||
# Save OpenAPI schema to JSON file | ||
with open(OUTPUT_FILE, "w") as f: | ||
json.dump(openapi_schema, f, indent=2) | ||
|
||
print(f"✅ OpenAPI schema saved to {OUTPUT_FILE}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters