diff --git a/api/specs/webserver/openapi-announcements.yaml b/api/specs/webserver/openapi-announcements.yaml new file mode 100644 index 000000000000..73a6c3687235 --- /dev/null +++ b/api/specs/webserver/openapi-announcements.yaml @@ -0,0 +1,79 @@ +paths: + /announcements: + get: + tags: + - announcements + summary: List Announcements + operationId: list_announcements + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/Envelope_list_simcore_service_webserver.announcements._models.Announcement__' +components: + schemas: + Announcement: + properties: + id: + type: string + title: Id + products: + items: + type: string + enum: + - osparc + - s4l + - s4llite + - tis + type: array + title: Products + start: + type: string + format: date-time + title: Start + end: + type: string + format: date-time + title: End + title: + type: string + title: Title + description: + type: string + title: Description + link: + type: string + title: Link + widgets: + items: + type: string + enum: + - login + - ribbon + - user-menu + type: array + title: Widgets + type: object + required: + - id + - products + - start + - end + - title + - description + - link + - widgets + title: Announcement + Envelope_list_simcore_service_webserver.announcements._models.Announcement__: + properties: + data: + items: + $ref: '#/components/schemas/Announcement' + type: array + title: Data + error: + title: Error + type: object + title: Envelope[list[simcore_service_webserver.announcements._models.Announcement]] diff --git a/api/specs/webserver/openapi.yaml b/api/specs/webserver/openapi.yaml index 0347da356be5..c433e8e42929 100644 --- a/api/specs/webserver/openapi.yaml +++ b/api/specs/webserver/openapi.yaml @@ -45,6 +45,10 @@ paths: /email:test: $ref: "./openapi-admin.yaml#/paths/~1email:test" + # ANNOUNCEMENTS --------------------------------------------------------- + /announcements: + $ref: "./openapi-announcements.yaml#/paths/~1announcements" + # DIAGNOSTICS --------------------------------------------------------- /: $ref: "./openapi-diagnostics.yaml#/paths/~1" diff --git a/api/specs/webserver/scripts/openapi_announcements.py b/api/specs/webserver/scripts/openapi_announcements.py new file mode 100644 index 000000000000..9119d41b3312 --- /dev/null +++ b/api/specs/webserver/scripts/openapi_announcements.py @@ -0,0 +1,36 @@ +""" Helper script to generate OAS automatically +""" + +# pylint: disable=redefined-outer-name +# pylint: disable=unused-argument +# pylint: disable=unused-variable +# pylint: disable=too-many-arguments + + +from enum import Enum + +from fastapi import FastAPI +from models_library.generics import Envelope +from simcore_service_webserver.announcements._handlers import Announcement + +app = FastAPI(redoc_url=None) + +TAGS: list[str | Enum] = [ + "announcements", +] + + +@app.get( + "/announcements", + response_model=Envelope[list[Announcement]], + tags=TAGS, + operation_id="list_announcements", +) +async def list_announcements(): + ... + + +if __name__ == "__main__": + from _common import CURRENT_DIR, create_openapi_specs + + create_openapi_specs(app, CURRENT_DIR.parent / "openapi-announcements.yaml") diff --git a/api/specs/webserver/scripts/requirements.txt b/api/specs/webserver/scripts/requirements.txt index da8883a7c951..414710b0389f 100644 --- a/api/specs/webserver/scripts/requirements.txt +++ b/api/specs/webserver/scripts/requirements.txt @@ -1,4 +1,4 @@ # Extra reqs, besides webserver's -fastapi +fastapi<0.100 jsonref