Skip to content

Commit

Permalink
[Ops] Add command to get OpenAPI definition from the server.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarciani committed Nov 7, 2024
1 parent 71d39e4 commit 784569c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ops/src/yawa_ops/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from yawa_ops.commands.admin import send_mail
from yawa_ops.commands.auth.login import login
from yawa_ops.commands.auth.logout import logout
from yawa_ops.commands.docs.openapi import openapi
from yawa_ops.commands.management import info, shutdown, health
from yawa_ops.commands.simple.get_outcome import get_outcome
from yawa_ops.commands.simple.get_greetings import get_greetings
Expand Down Expand Up @@ -33,6 +34,9 @@ def main(ctx, debug=False):
main.add_command(health)
main.add_command(shutdown)

# Docs
main.add_command(openapi)

# Admin
main.add_command(send_mail)

Expand Down
17 changes: 17 additions & 0 deletions ops/src/yawa_ops/commands/docs/openapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import click
from yawac.apis.paths.docs_openapi import DocsOpenapi
from yawac.paths.simple_greetings.get import GetGreetings

from yawa_ops.commands.base_command import BaseCommand
from yawa_ops.utils import logutils
from yawa_ops.utils.api import build_client, print_response

log = logutils.get_logger(__name__)


@click.command(help="Get OpenAPI definition.", cls=BaseCommand)
@click.pass_context
def openapi(ctx, endpoint, profile, verify_ssl, ca_file, debug):
with build_client(**ctx.obj.get("CLIENT_CONFIG")) as api_client:
response = DocsOpenapi(api_client).get()
print_response(response)

0 comments on commit 784569c

Please sign in to comment.