Validation with body which is intended for plain-text#317
Validation with body which is intended for plain-text#317Vlczech wants to merge 2 commits into0b01001001:masterfrom
Conversation
| if hasattr(func, "body"): | ||
| content_items["text/plain"] = { | ||
| "schema": {"$ref": f"#/components/schemas/{func.body}"} | ||
| } |
There was a problem hiding this comment.
What will the BaseModel look like? Can you provide an example? If possible, can you add some tests?
There was a problem hiding this comment.
@kemingy It is intended for text inputs like CSV etc. BaseModel is used to describe data in this model and it can be like this:
class FooBarPostBodyData(BaseModel):
"""
CSV body for example for some import
"""
__root__: str = Field(description="Data in CSV format - it consists of columns name, surname, ..., ..., ... .")
There was a problem hiding this comment.
Sorry for the late response.
I feel that if we need to create a special argument for each MIME type, there will be endless arguments. By the way, they all belong to the request body. I wonder if we can add an attribute to the request model, for example, spec_mime_type or something else. This should be able to handle this kind of feature. What do you think?
There was a problem hiding this comment.
Yes, it could be useful to process on one place for multiple mime-types.
|
nice feature, I would also be interested in plain text / csv or also binary bodies. |
Yes. I think we can add the |
|
Still any plans on integrating this ? There is this fork https://github.com/turner-townsend/flask-pydantic-spec which took this approach in its design. My api supports application/bson as input format, along with application/json, that |
Yes. I plan to support all kinds of MIME, which might introduce some breaking changes in v2. |
No description provided.