Replies: 2 comments 5 replies
-
Could you provide an example where this is more convenient? The way it's currently implemented is a design choice. Having multiple instances of Starlite expects you to define the schema of the request body as is; It's one schema for one form. It's not any different than receiving a JSON body: You also wouldn't declare individual fields of it as independent parameters. It's one JSON object, and should be reflected as such. |
Beta Was this translation helpful? Give feedback.
-
Your point about the semantic issue with the concept of https://fastapi.tiangolo.com/tutorial/request-forms/ Perhaps using the term
Regarding an example where this proposal would help: There are times when API endpoints are used to perform some non-idempotent action that does not map neatly to a model-oriented REST POST/PUT/PATCH/DELETE scenario. Examples might include sending an email, performing a logout, etc. Often the POST verb is used in these cases. The request parameters for those endpoints do not represent the attributes of a model, so it doesn't make sense to require the API to define a model class in order to specify the parameters. Such model classes are used only once - to specify the parameters for the endpoint. Allowing the endpoint to specify As I was reflecting on this proposal, I realized that I should not have focused the proposal on form-encoded data. The scenarios apply whether the request data is encoded using As an alternative to introducing both
|
Beta Was this translation helpful? Give feedback.
-
Currently, Starlite supports validating submitted form data by defining a model class, like this:
In some cases, it would be convenient to receive form data via multiple route handler parameters. Other API frameworks such as hug and FastAPI allow this. Here's how that might look:
The Form() function would have a design similar to the existing Parameter() function, providing
pydantic
options for validation.Thanks for considering this!
Beta Was this translation helpful? Give feedback.
All reactions