0

sorry for this basic question but I would like some help from you expert as I am still learning fastaapi.

I have a simple testing application running python FastApi and trying to use it with azure cli.

what I am trying to do, is to have a get request using fastapi to list all the resource groups I have in my subscriptions.

Now, reading documentation and some forums, I have this code here:

@app.get("/azure")
def az_cli (args_str):
    temp = tempfile.TemporaryFile()
    args = args_str.split()
    code = get_default_cli().invoke(['login', '--service-principal', '-u', '', '-p', '','--tenant',''])
    resource = get_default_cli().invoke(args)
    data = temp.read().strip()
    temp.close()
    return [args, resource]

This def authenticate the user with service principle, and invoke a az command args.

If I run unicorn and head to docs and in the args field I type resource list the code work just fine, doesn't throw any error, but nothing shows in the request body. the full output though is visible in the terminal.

Can please somebody explain me how can I have the body output in the docs body?

Thank you very much for any help you can provide and I hope my example is clear enough, and if not please feel free to ask more informations.

Nayden Van
  • 1,133
  • 1
  • 23
  • 70
  • You can refer to [How to customize FastAPI request body documentation](https://stackoverflow.com/questions/68815761/how-to-customize-fastapi-request-body-documentation) and [How to add docs to post body model on fast api view?](https://stackoverflow.com/questions/62915625/how-to-add-docs-to-post-body-model-on-fast-api-view) – Ecstasy Sep 29 '21 at 10:07
  • Hi thank you very much for you reply. still the documentation didn't gave any highlights on how is possible to integrate the terminal output in `/docs` – Nayden Van Oct 09 '21 at 23:26

0 Answers0