Skip to content

Commit

Permalink
✨ Is686/webserver api 0.12: project ports metadata (#3621)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov authored Dec 1, 2022
1 parent 936bac0 commit c1d30ff
Show file tree
Hide file tree
Showing 11 changed files with 376 additions and 55 deletions.
109 changes: 98 additions & 11 deletions api/specs/webserver/openapi-projects-ports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Envelope_dict_uuid.UUID__simcore_service_webserver.projects.projects_ports_handlers.ProjectPortGet__'
$ref: '#/components/schemas/Envelope_dict_uuid.UUID__simcore_service_webserver.projects.projects_ports_handlers.ProjectInputGet__'
patch:
tags:
- project
Expand All @@ -42,15 +42,15 @@ paths:
title: Updates
type: array
items:
$ref: '#/components/schemas/ProjectPort'
$ref: '#/components/schemas/ProjectInputUpdate'
required: true
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/Envelope_dict_uuid.UUID__simcore_service_webserver.projects.projects_ports_handlers.ProjectPortGet__'
$ref: '#/components/schemas/Envelope_dict_uuid.UUID__simcore_service_webserver.projects.projects_ports_handlers.ProjectInputGet__'
/projects/{project_id}/outputs:
get:
tags:
Expand All @@ -72,18 +72,62 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Envelope_dict_uuid.UUID__simcore_service_webserver.projects.projects_ports_handlers.ProjectPortGet__'
$ref: '#/components/schemas/Envelope_dict_uuid.UUID__simcore_service_webserver.projects.projects_ports_handlers.ProjectOutputGet__'
/projects/{project_id}/metadata/ports:
get:
tags:
- project
summary: List Project Metadata Ports
description: New in version *0.12*
operationId: list_project_metadata_ports
parameters:
- required: true
schema:
title: Project Id
type: string
format: uuid
name: project_id
in: path
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/Envelope_list_simcore_service_webserver.projects.projects_ports_handlers.ProjectMetadataPortGet__'
components:
schemas:
Envelope_dict_uuid.UUID__simcore_service_webserver.projects.projects_ports_handlers.ProjectPortGet__:
title: Envelope[dict[uuid.UUID, simcore_service_webserver.projects.projects_ports_handlers.ProjectPortGet]]
Envelope_dict_uuid.UUID__simcore_service_webserver.projects.projects_ports_handlers.ProjectInputGet__:
title: Envelope[dict[uuid.UUID, simcore_service_webserver.projects.projects_ports_handlers.ProjectInputGet]]
type: object
properties:
data:
title: Data
type: object
additionalProperties:
$ref: '#/components/schemas/ProjectInputGet'
error:
title: Error
Envelope_dict_uuid.UUID__simcore_service_webserver.projects.projects_ports_handlers.ProjectOutputGet__:
title: Envelope[dict[uuid.UUID, simcore_service_webserver.projects.projects_ports_handlers.ProjectOutputGet]]
type: object
properties:
data:
title: Data
type: object
additionalProperties:
$ref: '#/components/schemas/ProjectPortGet'
$ref: '#/components/schemas/ProjectOutputGet'
error:
title: Error
Envelope_list_simcore_service_webserver.projects.projects_ports_handlers.ProjectMetadataPortGet__:
title: Envelope[list[simcore_service_webserver.projects.projects_ports_handlers.ProjectMetadataPortGet]]
type: object
properties:
data:
title: Data
type: array
items:
$ref: '#/components/schemas/ProjectMetadataPortGet'
error:
title: Error
HTTPValidationError:
Expand All @@ -95,11 +139,12 @@ components:
type: array
items:
$ref: '#/components/schemas/ValidationError'
ProjectPort:
title: ProjectPort
ProjectInputGet:
title: ProjectInputGet
required:
- key
- value
- label
type: object
properties:
key:
Expand All @@ -111,8 +156,50 @@ components:
value:
title: Value
description: Value assigned to this i/o port
ProjectPortGet:
title: ProjectPortGet
label:
title: Label
type: string
ProjectInputUpdate:
title: ProjectInputUpdate
required:
- key
- value
type: object
properties:
key:
title: Key
type: string
description: Project port's unique identifer. Same as the UUID of the associated
port node
format: uuid
value:
title: Value
description: Value assigned to this i/o port
ProjectMetadataPortGet:
title: ProjectMetadataPortGet
required:
- key
- kind
type: object
properties:
key:
title: Key
type: string
description: Project port's unique identifer. Same as the UUID of the associated
port node
format: uuid
kind:
title: Kind
enum:
- input
- output
type: string
content_schema:
title: Content Schema
type: object
description: jsonschema for the port's value. SEE https://json-schema.org/understanding-json-schema/
ProjectOutputGet:
title: ProjectOutputGet
required:
- key
- value
Expand Down
5 changes: 4 additions & 1 deletion api/specs/webserver/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.0
info:
title: "osparc-simcore web API"
version: 0.11.0
version: 0.12.0
description: "API designed for the front-end app"
contact:
name: IT'IS Foundation
Expand Down Expand Up @@ -240,6 +240,9 @@ paths:
/projects/{project_id}/outputs:
$ref: "./openapi-projects-ports.yaml#/paths/~1projects~1{project_id}~1outputs"

/projects/{project_id}/metadata/ports:
$ref: "./openapi-projects-ports.yaml#/paths/~1projects~1{project_id}~1metadata~1ports"

/nodes/{nodeInstanceUUID}/outputUi/{outputKey}:
$ref: "./openapi-node-v0.0.1.yaml#/paths/~1nodes~1{nodeInstanceUUID}~1outputUi~1{outputKey}"

Expand Down
33 changes: 23 additions & 10 deletions api/specs/webserver/scripts/openapi_projects_ports.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
""" Helper script to generate OAS automatically
""" Helper script to automatically generate OAS
This OAS are the source of truth
"""

# pylint: disable=redefined-outer-name
Expand All @@ -15,13 +17,12 @@
from models_library.projects import ProjectID
from models_library.projects_nodes import NodeID
from simcore_service_webserver.projects.projects_ports_handlers import (
ProjectPort,
ProjectPortGet,
ProjectInputGet,
ProjectInputUpdate,
ProjectMetadataPortGet,
ProjectOutputGet,
)

# TODO: how to ensure this is in sync with projects_ports_handlers.routes ??
# this is the source of truth.

app = FastAPI(redoc_url=None)

TAGS: list[Union[str, Enum]] = [
Expand All @@ -31,7 +32,7 @@

@app.get(
"/projects/{project_id}/inputs",
response_model=Envelope[dict[NodeID, ProjectPortGet]],
response_model=Envelope[dict[NodeID, ProjectInputGet]],
tags=TAGS,
operation_id="get_project_inputs",
)
Expand All @@ -41,24 +42,36 @@ async def get_project_inputs(project_id: ProjectID):

@app.patch(
"/projects/{project_id}/inputs",
response_model=Envelope[dict[NodeID, ProjectPortGet]],
response_model=Envelope[dict[NodeID, ProjectInputGet]],
tags=TAGS,
operation_id="update_project_inputs",
)
async def update_project_inputs(project_id: ProjectID, updates: list[ProjectPort]):
async def update_project_inputs(
project_id: ProjectID, updates: list[ProjectInputUpdate]
):
"""New in version *0.10*"""


@app.get(
"/projects/{project_id}/outputs",
response_model=Envelope[dict[NodeID, ProjectPortGet]],
response_model=Envelope[dict[NodeID, ProjectOutputGet]],
tags=TAGS,
operation_id="get_project_outputs",
)
async def get_project_outputs(project_id: ProjectID):
"""New in version *0.10*"""


@app.get(
"/projects/{project_id}/metadata/ports",
response_model=Envelope[list[ProjectMetadataPortGet]],
tags=TAGS,
operation_id="list_project_metadata_ports",
)
async def list_project_metadata_ports(project_id: ProjectID):
"""New in version *0.12*"""


if __name__ == "__main__":
from _common import CURRENT_DIR, create_openapi_specs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ..services_constants import PROPERTY_TYPE_TO_PYTHON_TYPE_MAP

PortKindStr = Literal["input", "output"]
JsonSchemaDict = dict[str, Any]

_PROPERTY_TYPE_TO_SCHEMAS = {
property_type: schema_of(python_type, title=property_type.capitalize())
Expand Down Expand Up @@ -36,7 +37,7 @@ def update_schema_doc(schema: dict[str, Any], port: Union[ServiceInput, ServiceO

def get_service_io_json_schema(
port: Union[ServiceInput, ServiceOutput]
) -> Optional[dict[str, Any]]:
) -> Optional[JsonSchemaDict]:
"""Get json-schema for a i/o service
For legacy metadata with property_type = integer, etc ... , it applies a conversion
Expand Down
2 changes: 1 addition & 1 deletion services/web/server/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.0
0.12.0
2 changes: 1 addition & 1 deletion services/web/server/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.11.0
current_version = 0.12.0
commit = True
message = services/webserver api version: {current_version} → {new_version}
tag = False
Expand Down
Loading

0 comments on commit c1d30ff

Please sign in to comment.