Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenAPI schema definition #74

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

tiran
Copy link
Contributor

@tiran tiran commented Oct 20, 2022

The multiplexer now provides OpenAPI schema for public API endpoints. Starlette's API schema generator uses a mix of introspection and YAML in doc strings. The schema is available under /api/webconsole/v1/schema path and python appservice/multiplexer.py schema on the command line.

The SchemaGenerator introduces a new dependency on pyyaml package.

See: https://www.starlette.io/schemas/

The multiplexer now provides OpenAPI schema for public API endpoints.
Starlette's API schema generator uses a mix of introspection and YAML in
doc strings. The schema is available under `/api/webconsole/v1/schema`
path and `python appservice/multiplexer.py schema` on the command line.

The SchemaGenerator introduces a new dependency on `pyyaml` package.

See: https://www.starlette.io/schemas/
@tiran
Copy link
Contributor Author

tiran commented Oct 20, 2022

Example output:

$ ./.venv/bin/python appservice/multiplexer.py schema
info:
  title: webconsole
  version: '1.0'
openapi: 3.0.0
paths:
  /api/webconsole/v1/ping:
    get:
      responses:
        200:
          description: Returns pong
      summary: Ping service
  /api/webconsole/v1/sessions/new:
    post:
      response:
        200:
          description: new session
          example: '{"id": "42cdaa42-413a-40fa-b5b5-29c2a8ad8555"}'
        500:
          description: time out
      summary: Create a new session
  /api/webconsole/v1/sessions/{sessionid}/status:
    get:
      response:
        200:
          description: session status (running, closed, wait_target)
        404:
          description: unknown session id
      summary: Get session status
  /api/webconsole/v1/sessions/{sessionid}/wait-running:
    get:
      response:
        200:
          description: session is running
        404:
          description: unknown session id
      summary: Wait for session
  /wss/webconsole/v1/sessions/{sessionid}/web/{path}:
    get:
      response:
        200:
          description: success
        404:
          description: unknown session id
      summary: reverse-proxy cockpit HTTP to session pod

@marusak
Copy link
Member

marusak commented Nov 15, 2022

  /wss/webconsole/v1/sessions/{sessionid}/web/{path}:
    get:
      response:
        200:
          description: success
        404:
          description: unknown session id
      summary: reverse-proxy cockpit HTTP to session pod

This is a bit weird, we have wss://console.redhat.com/wss/webconsole/v1/sessions/<session_id>/ws and https://console.redhat.com/wss/webconsole/v1/sessions/<session_id>/web endpoints. The ws is missing and the web is defined with path which is not really the way it is defined as endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants