Skip to content

Using FastAPI for coverage existing API #1884

@alex-pancho

Description

@alex-pancho

How I can covered existing API?
For example if i use:

import uvicorn
from typing import Optional

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}

if __name__ == '__main__':
    uvicorn.run("api_fastapi_small:app", port=8080, reload=True)

this return localhost calls:
Curl
curl -X GET "http://127.0.0.1:8080/" -H "accept: application/json"
Request URL
http://127.0.0.1:8080/

But if I need send and create documentation for https://somesite.com/api/
How i can change this?
I just need to describe the existing API that can be implemented, for example on PHP and runs on another server.

I also find similar question, but the documents referred to are missing (404) #1108

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions