Skip to content

Commit

Permalink
Add method-name and group-name to openapi schema
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Aug 2, 2024
1 parent e318e0b commit 88dd5b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions daras_ai_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ def sentry_event_set_user(self, event, hint):
}
return event

@classmethod
def get_openapi_extra(cls) -> dict[str, typing.Any]:
return {
"x-fern-sdk-group-name": cls.slug_versions[-1].title().replace("-", ""),
"x-fern-sdk-method-name": "status",
}

def refresh_state(self):
_, run_id, uid = extract_query_params(gui.get_query_params())
channel = self.realtime_channel_name(run_id, uid)
Expand Down
10 changes: 7 additions & 3 deletions routers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import typing
from types import SimpleNamespace

from fastapi import APIRouter
from fastapi import APIRouter, Query
from fastapi import Depends
from fastapi import Form
from fastapi import HTTPException
Expand Down Expand Up @@ -215,6 +215,7 @@ def run_api_form(
name=page_cls.title + " (v3 async)",
tags=[page_cls.title],
status_code=202,
openapi_extra=page_cls.get_openapi_extra(),
)
@app.post(
os.path.join(endpoint, "async"),
Expand All @@ -227,7 +228,7 @@ def run_api_json_async(
request: Request,
response: Response,
page_request: request_model,
example_id: str | None = None,
example_id: str | None = Query(default=None),
user: AppUser = Depends(api_auth_header),
):
ret = _run_api(
Expand Down Expand Up @@ -286,7 +287,10 @@ def run_api_form_async(
operation_id="status__" + page_cls.slug_versions[0],
tags=[page_cls.title],
name=page_cls.title + " (v3 status)",
openapi_extra={"x-fern-sdk-return-value": "output"},
openapi_extra={
"x-fern-sdk-return-value": "output",
**page_cls.get_openapi_extra(),
},
)
@app.get(
os.path.join(endpoint, "status"),
Expand Down

0 comments on commit 88dd5b5

Please sign in to comment.