You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-24Lines changed: 32 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,26 +142,27 @@ These can be used in tandem to describe a parameter to validate: `parameter_name
142
142
### Validation with arguments to Parameter
143
143
Validation beyond type-checking can be done by passing arguments into the constructor of the `Parameter` subclass. The arguments available for use on each type hint are:
144
144
145
-
| Parameter Name | Type of Argument | Effective On Types | Description |
|`default`| any | All, except in `Route`| Specifies the default value for the field, makes non-Optional fields not required |
148
-
|`min_str_length`|`int`|`str`| Specifies the minimum character length for a string input |
149
-
|`max_str_length`|`int`|`str`| Specifies the maximum character length for a string input |
150
-
|`min_list_length`|`int`|`list`| Specifies the minimum number of elements in a list |
151
-
|`max_list_length`|`int`|`list`| Specifies the maximum number of elements in a list |
152
-
|`min_int`|`int`|`int`| Specifies the minimum number for an integer input |
153
-
|`max_int`|`int`|`int`| Specifies the maximum number for an integer input |
154
-
|`whitelist`|`str`|`str`| A string containing allowed characters for the value |
155
-
|`blacklist`|`str`|`str`| A string containing forbidden characters for the value |
156
-
|`pattern`|`str`|`str`| A regex pattern to test for string matches |
157
-
|`func`|`Callable[Any] -> Union[bool, tuple[bool, str]]`| All | A function containing a fully customized logic to validate the value. See the [custom validation function](#custom-validation-function) below for usage |
158
-
|`datetime_format`|`str`|`datetime.datetime`| Python datetime format string datetime format string ([datetime format codes](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes)) |
159
-
|`comment`|`str`| All | A string to display as the argument description in any generated documentation |
160
-
|`alias`|`str`| All but `FileStorage`| An expected parameter name to receive instead of the function name. |
161
-
|`json_schema`|`dict`|`dict`| An expected [JSON Schema](https://json-schema.org) which the dict input must conform to |
|`default`| any | All, except in `Route`| Specifies the default value for the field, makes non-Optional fields not required |
148
+
|`min_str_length`|`int`|`str`| Specifies the minimum character length for a string input |
149
+
|`max_str_length`|`int`|`str`| Specifies the maximum character length for a string input |
150
+
|`min_list_length`|`int`|`list`| Specifies the minimum number of elements in a list |
151
+
|`max_list_length`|`int`|`list`| Specifies the maximum number of elements in a list |
152
+
|`min_int`|`int`|`int`| Specifies the minimum number for an integer input |
153
+
|`max_int`|`int`|`int`| Specifies the maximum number for an integer input |
154
+
|`whitelist`|`str`|`str`| A string containing allowed characters for the value |
155
+
|`blacklist`|`str`|`str`| A string containing forbidden characters for the value |
156
+
|`pattern`|`str`|`str`| A regex pattern to test for string matches |
157
+
|`func`|`Callable[Any] -> Union[bool, tuple[bool, str]]`| All | A function containing a fully customized logic to validate the value. See the [custom validation function](#custom-validation-function) below for usage |
158
+
|`datetime_format`|`str`|`datetime.datetime`| Python datetime format string datetime format string ([datetime format codes](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes)) |
159
+
|`comment`|`str`| All | A string to display as the argument description in any generated documentation |
160
+
|`alias`|`str`| All but `FileStorage`| An expected parameter name to receive instead of the function name. |
161
+
|`json_schema`|`dict`|`dict`| An expected [JSON Schema](https://json-schema.org) which the dict input must conform to |
|`min_length`|`int`|`FileStorage`| Minimum `Content-Length` for a file |
164
+
|`max_length`|`int`|`FileStorage`| Maximum `Content-Length` for a file |
165
+
|`blank_none`|`bool`|`Optional[str]`| If `True`, an empty string will be converted to `None`, defaults to configured `FPV_BLANK_NONE`, see [Validation Behavior Configuration](#validation-behavior-configuration) for more |
165
166
166
167
These validators are passed into the `Parameter` subclass in the route function, such as:
Using the data provided through parameters, docstrings, and Flask route registrations, Flask Parameter Validation can generate API Documentation in various formats.
188
-
To make this easy to use, it comes with a `Blueprint` and the output and configuration options below:
187
+
### Configuration Options
189
188
190
-
#### Format
189
+
#### API Documentation Configuration
191
190
*`FPV_DOCS_SITE_NAME: str`: Your site's name, to be displayed in the page title, default: `Site`
192
191
*`FPV_DOCS_CUSTOM_BLOCKS: array`: An array of dicts to display as cards at the top of your documentation, with the (optional) keys:
193
192
*`title: Optional[str]`: The title of the card
194
193
*`body: Optional[str] (HTML allowed)`: The body of the card
195
194
*`order: int`: The order in which to display this card (out of the other custom cards)
196
195
*`FPV_DOCS_DEFAULT_THEME: str`: The default theme to display in the generated webpage
197
196
197
+
See the [API Documentation](#api-documentation) below for other information on API Documentation generation
198
+
199
+
#### Validation Behavior Configuration
200
+
*`FPV_BLANK_NONE: bool`: Globally override the default `blank_none` behavior for routes in your application, defaults to `False` if unset
201
+
202
+
### API Documentation
203
+
Using the data provided through parameters, docstrings, and Flask route registrations, Flask Parameter Validation can generate API Documentation in various formats.
204
+
To make this easy to use, it comes with a `Blueprint` and the output shown below and configuration options [above](#api-documentation-configuration):
205
+
198
206
#### Included Blueprint
199
207
The documentation blueprint can be added using the following code:
0 commit comments