Skip to content

Commit

Permalink
Improve OpenAPI spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Aug 2, 2024
1 parent 6c01a5f commit ef00a98
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "mass"
version = "3.0.0"
description = "Metadata Artifact Search Service - A service for searching metadata artifacts and filtering results."
description = "Metadata Artifact Search Service - A service for searching metadata artifacts and filtering results."
dependencies = [
"typer>=0.12",
"ghga-service-commons[api]>=3.1.5",
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Mass

Metadata Artifact Search Service - A service for searching metadata artifacts and filtering results.
Metadata Artifact Search Service - A service for searching metadata artifacts and filtering results.

## Description

Expand Down Expand Up @@ -307,9 +307,9 @@ The service requires the following configuration parameters:
## Definitions


- <a id="%24defs/FieldLabel"></a>**`FieldLabel`** *(object)*: Contains the key and corresponding user-friendly name for a field.
- <a id="%24defs/FieldLabel"></a>**`FieldLabel`** *(object)*: Contains the field name and corresponding user-friendly name.

- **`key`** *(string, required)*: The raw field key, such as study.type.
- **`key`** *(string, required)*: The raw field name, such as study.type.

- **`name`** *(string)*: A user-friendly name for the field (leave empty to use the key). Default: `""`.

Expand Down
4 changes: 2 additions & 2 deletions config_schema.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$defs": {
"FieldLabel": {
"description": "Contains the key and corresponding user-friendly name for a field",
"description": "Contains the field name and corresponding user-friendly name",
"properties": {
"key": {
"description": "The raw field key, such as study.type",
"description": "The raw field name, such as study.type",
"title": "Key",
"type": "string"
},
Expand Down
13 changes: 9 additions & 4 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ components:
the facet
properties:
key:
description: The raw field key, such as study.type
description: The raw field name, such as study.type
title: Key
type: string
name:
Expand Down Expand Up @@ -42,10 +42,10 @@ components:
title: FacetOption
type: object
FieldLabel:
description: Contains the key and corresponding user-friendly name for a field
description: Contains the field name and corresponding user-friendly name
properties:
key:
description: The raw field key, such as study.type
description: The raw field name, such as study.type
title: Key
type: string
name:
Expand Down Expand Up @@ -175,7 +175,12 @@ components:
title: ValidationError
type: object
info:
title: A service for searching metadata artifacts and filtering results.
contact:
email: [email protected]
license:
name: Apache 2.0
summary: A service for searching metadata artifacts and filtering results.
title: Metadata Artifact Search Service
version: 3.0.0
openapi: 3.1.0
paths:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers = [
]
name = "mass"
version = "3.0.0"
description = "Metadata Artifact Search Service - A service for searching metadata artifacts and filtering results."
description = "Metadata Artifact Search Service - A service for searching metadata artifacts and filtering results."
dependencies = [
"typer>=0.12",
"ghga-service-commons[api]>=3.1.5",
Expand Down
7 changes: 5 additions & 2 deletions src/mass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

"""A service for searching metadata artifacts and filtering results."""

from importlib.metadata import version
from importlib.metadata import distribution

__version__ = version(__package__)
dist = distribution(__package__)
metadata = dist.metadata

__version__ = dist.version
31 changes: 21 additions & 10 deletions src/mass/adapters/inbound/fastapi_/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,34 @@
from fastapi import FastAPI
from ghga_service_commons.api import configure_app

import mass
from mass import metadata
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."""
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__
summary = metadata["Summary"]
author = metadata["Author"]
email = metadata["Author-email"]
license = metadata["License"]
title, summary = summary.split(" - ", 1)
contact = {
"name": author,
"email": email,
}
license_info = {
"name": license,
}
version = metadata["Version"]

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

Expand Down

0 comments on commit ef00a98

Please sign in to comment.