Skip to content

Commit

Permalink
Merge pull request #16 from TranslatorSRI/update_openapi
Browse files Browse the repository at this point in the history
Update openapi
  • Loading branch information
maximusunc authored Oct 12, 2023
2 parents fc8f4f7 + ad962ef commit 38d577d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ logs/*
*.jar
.env
*.log
kgx/
kgx/
data/
2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Settings(BaseSettings):
openapi_server_url: Optional[AnyUrl]
openapi_server_url: AnyUrl = "http://localhost:9096"
openapi_server_maturity: str = "development"
openapi_server_location: str = "RENCI"
trapi_version: str = "1.4.0"
Expand Down
14 changes: 6 additions & 8 deletions app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
LOGGER = logging.getLogger(__name__)

openapi_args = dict(
title="Answer Appraiser",
version="0.3.4",
title="SRI Answer Appraiser",
version="0.3.5",
terms_of_service="",
translator_component="Utility",
translator_teams=["Standards Reference Implementation Team"],
infores="infores:answer-appraiser",
description="SRI service that provides metrics for scoring and ordering of results",
trapi="1.4.0",
biolink_version="3.4.2",
contact={
"name": "Max Wang",
"email": "[email protected]",
"x-id": "maximusunc",
"x-id": "https://github.com/maximusunc",
"x-role": "responsible developer",
},
)
Expand All @@ -43,8 +43,6 @@
},
]

openapi_args["trapi"] = settings.trapi_version

APP = TRAPI(**openapi_args)

APP.add_middleware(
Expand Down
21 changes: 16 additions & 5 deletions app/trapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@ def __init__(
self,
*args,
contact: Optional[Dict[str, Any]] = None,
description: Optional[str] = "",
terms_of_service: Optional[str] = None,
translator_component: Optional[str] = None,
translator_teams: Optional[List[str]] = None,
infores: Optional[str] = None,
trapi: Optional[str] = None,
biolink_version: Optional[str] = None,
servers: Optional[List[Dict]] = None,
**kwargs,
):
super().__init__(*args, **kwargs)
self.contact = contact
self.description = description
self.terms_of_service = terms_of_service
self.translator_component = translator_component
self.translator_teams = translator_teams
self.infores = infores
self.trapi = trapi
self.biolink_version = biolink_version
self.servers = servers

def openapi(self) -> Dict[str, Any]:
"""Build custom OpenAPI schema."""
Expand All @@ -51,24 +57,29 @@ def openapi(self) -> Dict[str, Any]:

openapi_schema["servers"] = self.servers

openapi_schema["info"]["contact"] = self.contact

openapi_schema["info"]["x-translator"] = {
"component": self.translator_component,
"team": self.translator_teams,
"biolink-version": self.biolink_version,
"component": "Utility",
"team": "Standards Reference Implementation Team",
"externalDocs": {
"description": "The values for component and team are restricted according to this external JSON schema. See schema and examples at url",
"url": "https://github.com/NCATSTranslator/translator_extensions/blob/production/x-translator/",
},
"infores": self.infores,
"infores": "infores:sri-answer-appraiser",
}
openapi_schema["info"]["x-trapi"] = {
"version": self.trapi,
"externalDocs": {
"description": "The values for version are restricted according to the regex in this external JSON schema. See schema and examples at url",
"url": "https://github.com/NCATSTranslator/translator_extensions/blob/production/x-trapi/",
},
"operations": [],
}
openapi_schema["info"]["contact"] = self.contact
openapi_schema["info"]["termsOfService"] = self.terms_of_service

if self.terms_of_service:
openapi_schema["info"]["termsOfService"] = self.terms_of_service

self.openapi_schema = openapi_schema
return self.openapi_schema
14 changes: 12 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
version: '3.7'

services:
workflow_runner:
answer_appraiser:
image: answer-appraiser
container_name: answer_appraiser
build:
context: .
ports:
- '${PORT:-9096}:9096'
- '${PORT:-9096}:9096'
redis:
image: redis/redis-stack-server:latest
container_name: answer_appraiser_redis
build:
context: redis
ports:
- "6379:6379"
restart: unless-stopped
volumes:
- ./data:/data

0 comments on commit 38d577d

Please sign in to comment.