mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-25 09:21:04 +00:00
Fix API Docs link
This commit is contained in:
parent
4bb4beee16
commit
c5cc233aaf
2 changed files with 11 additions and 9 deletions
|
@ -106,6 +106,9 @@ def create_app(args):
|
||||||
|
|
||||||
from libretranslate.language import load_languages
|
from libretranslate.language import load_languages
|
||||||
|
|
||||||
|
SWAGGER_URL = args.url_prefix + "/docs" # Swagger UI (w/o trailing '/')
|
||||||
|
API_URL = args.url_prefix + "/spec"
|
||||||
|
|
||||||
bp = Blueprint('Main app', __name__)
|
bp = Blueprint('Main app', __name__)
|
||||||
|
|
||||||
if not args.disable_files_translation:
|
if not args.disable_files_translation:
|
||||||
|
@ -279,7 +282,8 @@ def create_app(args):
|
||||||
api_keys=args.api_keys,
|
api_keys=args.api_keys,
|
||||||
get_api_key_link=args.get_api_key_link,
|
get_api_key_link=args.get_api_key_link,
|
||||||
web_version=os.environ.get("LT_WEB") is not None,
|
web_version=os.environ.get("LT_WEB") is not None,
|
||||||
version=get_version()
|
version=get_version(),
|
||||||
|
swagger_url=SWAGGER_URL
|
||||||
)
|
)
|
||||||
|
|
||||||
@bp.get("/javascript-licenses")
|
@bp.get("/javascript-licenses")
|
||||||
|
@ -993,21 +997,19 @@ def create_app(args):
|
||||||
app.register_blueprint(bp)
|
app.register_blueprint(bp)
|
||||||
|
|
||||||
swag = swagger(app)
|
swag = swagger(app)
|
||||||
swag["info"]["version"] = "1.3.1"
|
swag["info"]["version"] = get_version()
|
||||||
swag["info"]["title"] = "LibreTranslate"
|
swag["info"]["title"] = "LibreTranslate"
|
||||||
|
|
||||||
@app.route("/spec")
|
|
||||||
|
@app.route(API_URL)
|
||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
def spec():
|
def spec():
|
||||||
return jsonify(swag)
|
return jsonify(swag)
|
||||||
|
|
||||||
SWAGGER_URL = "/docs" # URL for exposing Swagger UI (without trailing '/')
|
|
||||||
API_URL = "/spec"
|
|
||||||
|
|
||||||
# Call factory function to create our blueprint
|
# Call factory function to create our blueprint
|
||||||
swaggerui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL)
|
swaggerui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL)
|
||||||
if args.url_prefix:
|
if args.url_prefix:
|
||||||
app.register_blueprint(swaggerui_blueprint, url_prefix=args.url_prefix)
|
app.register_blueprint(swaggerui_blueprint, url_prefix=SWAGGER_URL)
|
||||||
else:
|
else:
|
||||||
app.register_blueprint(swaggerui_blueprint)
|
app.register_blueprint(swaggerui_blueprint)
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<span>LibreTranslate</span>
|
<span>LibreTranslate</span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="right hide-on-med-and-down">
|
<ul class="right hide-on-med-and-down">
|
||||||
<li><a href="/docs">API Docs</a></li>
|
<li><a href="{{ swagger_url }}">API Docs</a></li>
|
||||||
{% if get_api_key_link %}
|
{% if get_api_key_link %}
|
||||||
<li><a href="{{ get_api_key_link }}">Get API Key</a></li>
|
<li><a href="{{ get_api_key_link }}">Get API Key</a></li>
|
||||||
<script>window.getApiKeyLink = "{{ get_api_key_link }}";</script>
|
<script>window.getApiKeyLink = "{{ get_api_key_link }}";</script>
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul id="nav-mobile" class="sidenav">
|
<ul id="nav-mobile" class="sidenav">
|
||||||
<li><a href="/docs">API Docs</a></li>
|
<li><a href="{{ swagger_url }}">API Docs</a></li>
|
||||||
{% if get_api_key_link %}
|
{% if get_api_key_link %}
|
||||||
<li><a href="{{ get_api_key_link }}">Get API Key</a></li>
|
<li><a href="{{ get_api_key_link }}">Get API Key</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue