Bug: OpenAPI spec generation returns wrong type for IPv4Network and IPv6Network types
Author: takedaCreated Sep 7, 2026Updated Sep 7, 2026
LabelsBug :bug:
Description
Clients that are strict (for example aiopenapi3) fail when parsing response that contains IPv4Network and IPv6Network
It looks like the code here: https://github.com/litestar-org/litestar/blob/e3b6a1d103a9160a575dce01ae34839e6e9bf990/litestar/_openapi/schema_generation/schema.py#L90
maps it to "ipv4" and "ipv6" respectfully, but there seems to be "ipv4-cidr" and "ipv6-cidr"
https://spec.openapis.org/registry/format/ipv4-cidr.html https://spec.openapis.org/registry/format/ipv6-cidr.html
Any idea if there's a workaround for this?
URL to code causing the issue
No response
MCVE
Steps to reproduce
- create API which uses IPv4Network as response type and return CIDR
- use client like aiopenapi3 to process the response
Screenshots
No response
Logs
Litestar Version
v2.24.0
Platform
- Linux
- Mac
- Windows
- Other (Please specify in the description above)
Source: litestar-org/litestar