Skip to content

Commit be8624e

Browse files
committed
swagger interface customization
1 parent 4a67afc commit be8624e

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

bio-api/bioapi.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import gzip
55
import logging
6+
from turtle import title
67

78
from apispec import APISpec
89
from apispec.ext.marshmallow import MarshmallowPlugin
@@ -652,8 +653,12 @@ def associated_string_genes(gene_symbol: str, min_combined_score: int = 400) ->
652653
spec = APISpec(
653654
title="BioAPI",
654655
version=VERSION,
655-
openapi_version="2.0.1",
656-
info=dict(description="A powerful abstraction of genomics databases."),
656+
openapi_version="2.0.0",
657+
info=dict(
658+
description="""
659+
## A powerful abstraction of genomics databases.
660+
BioAPI is part of the Multiomix project. For more information, visit our [website](https://omicsdatascience.org/).
661+
To contribute: [OmicsDatascience](https://github.com/omics-datascience/BioAPI)"""),
657662
plugins=[FlaskPlugin(), MarshmallowPlugin()]
658663
)
659664

@@ -667,13 +672,17 @@ def create_app():
667672
# Spec API url or path
668673
API_URL = '/static/apispec.json'
669674

670-
# Call factory function to create our blueprint
671-
swaggerui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL, config={
672-
'operationsSorter': 'alpha',
673-
'tagsSorter': 'alpha',
674-
"defaultModelsExpandDepth": -1, # Oculta la sección "Models"
675-
'filter': True # Permite usar un campo de búsqueda para filtrar métodos en Swagger UI
676-
})
675+
# Config and Call factory function to create our blueprint
676+
swagger_ui_config = {
677+
'docExpansion': False, # Avoid extended tags
678+
'displayRequestDuration': False, # Hide the duration of the request
679+
'tryItOutEnabled': False, # Enables testing functions without clicking "Try it out"
680+
'supportedSubmitMethods': ['get', 'post'], # Allows testing only GET and POST methods
681+
'validatorUrl': False, # Avoid online validation of documentation
682+
"defaultModelsExpandDepth": -1, # Hide the Models section
683+
'filter': False, # Hide the method filter field
684+
}
685+
swaggerui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL, config=swagger_ui_config)
677686
flask_app.register_blueprint(swaggerui_blueprint)
678687

679688
flask_app.config.update({'APISPEC_SPEC': spec, 'APISPEC_SWAGGER_UI_URL': SWAGGER_URL})
@@ -684,8 +693,7 @@ def create_app():
684693
@flask_app.route(API_URL)
685694
def swagger_json():
686695
""" Path to get OpenAPI Spec in ${API_URL}"""
687-
schema = app.config['APISPEC_SPEC'].to_dict()
688-
696+
schema = app.config['APISPEC_SPEC'].to_dict()
689697
for path, methods in schema.get("paths", {}).items():
690698
methods.pop("options", None)
691699

0 commit comments

Comments
 (0)