Skip to content

Commit

Permalink
Add-globalSearch-operation (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
csadorf committed Jun 1, 2022
1 parent 6ff3e74 commit 98320f4
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 0 deletions.
21 changes: 21 additions & 0 deletions marketplace_standard_app_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from fastapi.responses import HTMLResponse, JSONResponse, Response

from .models.data_sink import DatasetCreateResponse, DatasetId, DatasetModel
from .models.system import GlobalSearchResponse
from .models.transformation import (
NewTransformationModel,
TransformationCreateResponse,
Expand Down Expand Up @@ -71,6 +72,26 @@ async def frontpage() -> HTMLResponse:
raise HTTPException(status_code=501, detail="Not implemented.")


@api.get(
"/globalSearch",
operation_id="globalSearch",
tags=["System"],
responses={
401: {"description": "Not authenticated."},
422: {"description": "Validation error."},
500: {"description": "Internal server error."},
501: {"description": "Not implemented."},
503: {"description": "Service unavailable."},
},
response_model=GlobalSearchResponse,
)
async def global_search(
query: str, limit: Optional[int] = 100, offset: Optional[int] = 0
) -> GlobalSearchResponse:
"""Respond to global search queries."""
raise HTTPException(status_code=501, detail="Not implemented.")


@api.get(
"/health",
operation_id="heartbeat",
Expand Down
26 changes: 26 additions & 0 deletions marketplace_standard_app_api/models/system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import List, Optional

from pydantic import AnyUrl, BaseModel, Field


class GlobalSearchResponseItemModel(BaseModel):
"""Default query reply model"""

label: Optional[str] = Field(
None, description="Short label describing the search result"
)
description: Optional[str] = Field(
None, description="Short label describing the search result"
)
url: Optional[AnyUrl] = Field(None, description="URL to search results")
score: Optional[float] = Field(
None,
description=(
"Semantic relevance of search result. "
"Can be used to infer the ordering of search result"
),
)


class GlobalSearchResponse(BaseModel):
items: List[GlobalSearchResponseItemModel]
119 changes: 119 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,79 @@
]
}
},
"/globalSearch": {
"get": {
"tags": [
"System"
],
"summary": "Global Search",
"description": "Respond to global search queries.",
"operationId": "globalSearch",
"parameters": [
{
"required": true,
"schema": {
"title": "Query",
"type": "string"
},
"name": "query",
"in": "query"
},
{
"required": false,
"schema": {
"title": "Limit",
"type": "integer",
"default": 100
},
"name": "limit",
"in": "query"
},
{
"required": false,
"schema": {
"title": "Offset",
"type": "integer",
"default": 0
},
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GlobalSearchResponse"
}
}
}
},
"401": {
"description": "Not authenticated."
},
"422": {
"description": "Validation error."
},
"500": {
"description": "Internal server error."
},
"501": {
"description": "Not implemented."
},
"503": {
"description": "Service unavailable."
}
},
"security": [
{
"AuthTokenBearer": []
}
]
}
},
"/health": {
"get": {
"tags": [
Expand Down Expand Up @@ -621,6 +694,52 @@
"type": "object",
"properties": {}
},
"GlobalSearchResponse": {
"title": "GlobalSearchResponse",
"required": [
"items"
],
"type": "object",
"properties": {
"items": {
"title": "Items",
"type": "array",
"items": {
"$ref": "#/components/schemas/GlobalSearchResponseItemModel"
}
}
}
},
"GlobalSearchResponseItemModel": {
"title": "GlobalSearchResponseItemModel",
"type": "object",
"properties": {
"label": {
"title": "Label",
"type": "string",
"description": "Short label describing the search result"
},
"description": {
"title": "Description",
"type": "string",
"description": "Short label describing the search result"
},
"url": {
"title": "Url",
"maxLength": 65536,
"minLength": 1,
"type": "string",
"description": "URL to search results",
"format": "uri"
},
"score": {
"title": "Score",
"type": "number",
"description": "Semantic relevance of search result. Can be used to infer the ordering of search result"
}
},
"description": "Default query reply model"
},
"HTTPValidationError": {
"title": "HTTPValidationError",
"type": "object",
Expand Down

0 comments on commit 98320f4

Please sign in to comment.