Skip to content

Commit

Permalink
Merge pull request #58 from omics-datascience/swagger
Browse files Browse the repository at this point in the history
Swagger UI
  • Loading branch information
Genarito authored Jan 2, 2025
2 parents 43ebd33 + c0db3dc commit 6873a73
Show file tree
Hide file tree
Showing 10 changed files with 1,003 additions and 19 deletions.
32 changes: 30 additions & 2 deletions ModulectorBackend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import os

# Modulector version
VERSION: str = '2.2.0'
VERSION: str = '2.2.1'

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
Expand Down Expand Up @@ -53,7 +53,9 @@
'modulector.apps.ModulectorConfig',
'rest_framework',
'django_filters',
'django_generate_secret_key'
'django_generate_secret_key',
'drf_spectacular',
'drf_spectacular_sidecar'
]

CRONJOBS = [
Expand All @@ -78,8 +80,34 @@
# 'DEFAULT_PERMISSION_CLASSES': (
# 'rest_framework.permissions.DjangoModelPermissions',
# )
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'DEFAULT_AUTHENTICATION_CLASSES': [],
'DEFAULT_PERMISSION_CLASSES': []
}

SPECTACULAR_SETTINGS = {
'TITLE': 'Modulector',
'DESCRIPTION': """
### An open platform which provides information about methylation sites, miRNAs and genes from different popular databases.
The platform is part of the Multiomix project. For more information, visit our [website](https://omicsdatascience.org/).
To contribute: [OmicsDatascience](https://github.com/omics-datascience/modulector)""",
'VERSION': VERSION,
'SERVE_INCLUDE_SCHEMA': False,
'SWAGGER_UI_DIST': 'SIDECAR',
'SWAGGER_UI_FAVICON_HREF': 'SIDECAR',
'REDOC_DIST': 'SIDECAR',
'SCHEMA_PATH_PREFIX': '/api/',
'SWAGGER_UI_SETTINGS': {
'defaultModelsExpandDepth': -1,
'displayRequestDuration': False,
'docExpansion': 'none',
'filter': False,
'showExtensions': True,
'showCommonExtensions': True,
}
}


ROOT_URLCONF = 'ModulectorBackend.urls'

TEMPLATES = [
Expand Down
1 change: 1 addition & 0 deletions ModulectorBackend/settings_prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

# Disables Django REST Framework browsable API (in production only)
REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
)
Expand Down
5 changes: 5 additions & 0 deletions ModulectorBackend/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from django.contrib import admin
from django.urls import path
from modulector import views
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView


urlpatterns = [
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
path('admin/', admin.site.urls),
path('mirna/', views.MirnaList.as_view({'get': 'list'}), name='mirna'),
path('mirna-target-interactions/', views.MirnaTargetInteractions.as_view(),
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Modulector obtains information from different bioinformatics databases or resour

Modulector can be used through the graphical interfaces provided in [Multiomix][multiomix-site], or it can be hosted on your server (read [DEPLOYING.md](DEPLOYING.md) for more information). We strongly recommend using this software through the Multiomix application.

All services are available through a web API accessible from a browser or any other web client. All the responses are in JSON format. In addition to the information provided, sorting, filtering, searching, and paging functions are also available. How to use these functions is explained below:
All services are available through a web API accessible from a browser or web client, or you can try Modulector from its [Swagger interface](https://modulector.multiomix.org/api/schema/swagger-ui/). All the responses are in JSON format. In addition to the information provided, sorting, filtering, searching, and paging functions are also available. How to use these functions is explained below:


### General
Expand Down
2 changes: 2 additions & 0 deletions config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ django-filter==23.3
django-generate-secret-key==1.0.2
django-stubs==4.2.7
djangorestframework==3.14.0
drf-spectacular==0.28.0
drf-spectacular-sidecar==2024.12.1
mypy==1.9.0
pandas==2.1.2
psycopg2-binary==2.9.9
Expand Down
2 changes: 1 addition & 1 deletion docker-compose_dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:

# Django Backend Server
web_modulector:
image: omicsdatascience/modulector:2.2.0
image: omicsdatascience/modulector:2.2.1
restart: always
depends_on:
- db_modulector
Expand Down
2 changes: 1 addition & 1 deletion modulector/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Meta:
model = MirnaXGene
fields = ['id', 'mirna', 'gene', 'score',
'source_name', 'pubmeds', 'sources', 'score_class']

def get_pubmeds(self, mirna_gene_interaction: MirnaXGene) -> Set[str]:
"""
Gets a list of related Pubmed URLs to a miRNA-Gene interaction.
Expand Down
2 changes: 2 additions & 0 deletions modulector/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ <h2>Modulector v{{ version }}</h2>
<a href="{% url 'methylation_sites_to_genes' %}">Illumina Methylation Sites to Genes</a>
</li>
</ul>
<h3>You can use modulector features from the <a href="/api/schema/swagger-ui/" target="_blank">documentation</a> in Swagger</h3>
<h3><a href="/api/schema/redoc/" target="_blank">Documentation</a> in Redoc</h3>
</body>
</html>
Loading

0 comments on commit 6873a73

Please sign in to comment.