Voluptuous OpenAPI
Convert Voluptuous schemas to OpenAPI Schema object.
schema = {}
schema[vol.Required('name')] = vol.All(str, vol.Length(min=5))
schema[vol.Required('age', description='Age in full years')] = vol.All(vol.Coerce(int), vol.Range(min=18))
schema[vol.Optional('hobby', default='not specified')] = str
schema = vol.Schema(schema)
becomes
{
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 5,
},
"age": {
"type": "integer",
"minimum": 18,
"description": "Age in full years",
},
"hobby": {
"type": "string",
"default": "not specified",
},
},
"required": ["name", "age"],
}
See the tests for more examples.
Custom serializer
You can pass a custom serializer to be able to process custom validators. If the serializer returns UNSUPPORTED, it will return to normal processing. Example:
from voluptuous_openapi import UNSUPPORTED, convert
def custom_convert(value):
if value is my_custom_validator:
return {'pattern': '^[a-zA-Z0-9]$'}
return UNSUPPORTED
convert(value, custom_serializer=custom_convert)
Release files for voluptuous-openapi 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| voluptuous_openapi-0.4.1.tar.gz | 21.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| voluptuous_openapi-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.3 kB
Release files / voluptuous_openapi-0.4.1.tar.gz
| Download URL | voluptuous_openapi-0.4.1.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
745d0d60940a851d9a90c87eebf659c57072c9ef305c0f6f04f4fd7c063dc0ac
|
|
BLAKE2b-256 checksum How to use checksums |
60a5517c143607fd82cfc8842fcdccf5cf2c07cdd96528c936bde196e05dece3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / voluptuous_openapi-0.4.1-py3-none-any.whl
| Download URL | voluptuous_openapi-0.4.1-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b30abc527c622cd62dba1269a05099e6b6170678c2838908d347fa85ab0cdb44
|
|
BLAKE2b-256 checksum How to use checksums |
bcbb64db054ad3852e3b63841a570942d3ce29e6b44979d5ac4be806973a2338
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|