-
Notifications
You must be signed in to change notification settings - Fork 143
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
chore: Roll our openapi.json back into FastAPI #317
Comments
however, i believe at this point we need to maintain backwards compat of for pretty much all of the existing params. |
Hi @awalker4, I came across the "everything in the docs is a list" issue and I poked around to see if Pydantic was used or could be implemented/updated. Is there some history there? I see Pydantic listed in I'd be happy to contribute a PR for request models if that would be welcome. grep -r "pydantic" .
./requirements/base.in:pydantic<2.0.2
./requirements/test.txt:pydantic==1.10.13
./requirements/test.txt: # pydantic
./requirements/base.txt:pydantic==1.10.13
./requirements/base.txt: # pydantic
./requirements/base.txt: # pydantic-core
./prepline_general/api/general.py: # Note(austin): pydantic should control this sort of thing for us |
Actually I see the request is form data, which I don't think can be neatly wrapped in a Pydantic model. For backward compatibility with the array'd params, a Pydantic annotated validator could be used to take only the first element of the list as needed. The Swagger docs and the OpenAPI schema would only show the new types, so the backward compatibility would be undocumented. T = TypeVar("T")
def first_element_of_list(value: Union[T, list[T]]) -> T:
if isinstance(value, list) and len(value) > 0:
return value[0]
return value
@router.post("/general/v0/general")
def pipeline_1(
...
strategy: Annotated[
Literal["fast", "hi_res", "auto"],
Form(
title="Strategy",
description="The strategy to use for partitioning PDF/image. Options are fast, hi_res, auto. Default: auto",
examples=["auto", "hi_res"],
),
BeforeValidator(first_element_of_list),
] = "auto",
...
)
... ![]() |
A PR for this would be great! For context, we used to autogenerate this repo through unstructured-api-tools. That project generates FastAPI code from a Jupyter notebook, for quickly spinning up data pipelines. |
Closed with #359 |
The openapi.json in this repo is the source of truth for our Speakeasy client. We want to roll these changes back into FastAPI so they get into our hosted Swagger docs. The Speakeasy team has given us a diff to get started, so we just need to get this merged.
Note that many of our parameters are lists when they shouldn't be. Much of the complexity here is working around that in the generated spec,
so it might be cleaner to just fix the params first. Goal for this ticket should just be to apply the linked diff. We'll address the param types elsewhere.The text was updated successfully, but these errors were encountered: