Skip to content

Commit

Permalink
Add version and title to OpenAPI doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Aug 1, 2024
1 parent 4737159 commit a1eb80d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/.dev_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ searchable_classes:
name: Project Alias
selected_fields:
- key: accession
name: "Dataset ID"
name: Dataset ID
- key: title
name: Title

Expand Down
26 changes: 13 additions & 13 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
version: '3'

services:
app:
build:
context: .
dockerfile: ./Dockerfile
args:
# [Choice] Python version: 3, 3.8, 3.7, 3.6
VARIANT: 3.9
# [Choice] Install Node.js
INSTALL_NODE: "true"
NODE_VERSION: "lts/*"
# Please adapt to package name:
PACKAGE_NAME: "mass"
PACKAGE_NAME: mass
# On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000.
USER_UID: 1000
USER_GID: 1000
Expand All @@ -33,18 +25,26 @@ services:
environment:
# Please adapt to package name:
MASS_CONFIG_YAML: /workspace/.devcontainer/.dev_config.yaml
# Used by db migration:
DB_URL: postgresql://postgres:postgres@postgresql/postgres

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)


# Please remove service dependencies that are not needed:
mongodb:
image: mongo:latest
restart: unless-stopped
volumes:
- mongo_fs:/data/db

mongo-express:
image: mongo-express:latest
restart: unless-stopped
ports:
- 8088:8081
environment:
ME_CONFIG_MONGODB_URL: mongodb://mongodb:27017/
ME_CONFIG_BASICAUTH_USERNAME: dev
ME_CONFIG_BASICAUTH_PASSWORD: dev
ME_CONFIG_MONGODB_ENABLE_ADMIN: "true"

volumes:
mongo_fs: {}
4 changes: 2 additions & 2 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ components:
title: ValidationError
type: object
info:
title: FastAPI
version: 0.1.0
title: A service for searching metadata artifacts and filtering results.
version: 3.0.0
openapi: 3.1.0
paths:
/health:
Expand Down
8 changes: 3 additions & 5 deletions scripts/script_utils/fastapi_app_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

"""Used to define the location of the main FastAPI app object."""

from fastapi import FastAPI
from mass.adapters.inbound.fastapi_.configure import Config, get_configured_app

from mass.adapters.inbound.fastapi_.routes import router

app = FastAPI()
app.include_router(router)
config = Config() # type: ignore
app = get_configured_app(config=config)
12 changes: 11 additions & 1 deletion src/mass/adapters/inbound/fastapi_/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,23 @@
from fastapi import FastAPI
from ghga_service_commons.api import configure_app

import mass
from mass.adapters.inbound.fastapi_.routes import router
from mass.config import Config


def get_configured_app(*, config: Config) -> FastAPI:
"""Create and configure a REST API application."""
app = FastAPI()
doc = mass.__doc__
try:
title, description = mass.__doc__.split("\n\n", 1)
except ValueError:
title, description = doc, ""
title = title.strip()
description = description.strip()
version = mass.__version__

app = FastAPI(title=title, description=description, version=version)
app.include_router(router)
configure_app(app, config=config)

Expand Down

0 comments on commit a1eb80d

Please sign in to comment.