From a291a49a0e42ab44f226a6ef3eff11ed62a8ee8a Mon Sep 17 00:00:00 2001 From: yusing Date: Fri, 14 Nov 2025 22:28:29 +0800 Subject: [PATCH] fix(swagger): update netip.Addr definition type to string --- internal/api/v1/docs/swagger.json | 11 ++++++++++- scripts/fix-swagger-json.py | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/internal/api/v1/docs/swagger.json b/internal/api/v1/docs/swagger.json index 26e4d022..59b61075 100644 --- a/internal/api/v1/docs/swagger.json +++ b/internal/api/v1/docs/swagger.json @@ -5261,7 +5261,16 @@ "x-omitempty": false }, "netip.Addr": { - "type": "object", + "anyOf": [ + { + "type": "string", + "format": "ipv4" + }, + { + "type": "string", + "format": "ipv6" + } + ], "x-nullable": false, "x-omitempty": false }, diff --git a/scripts/fix-swagger-json.py b/scripts/fix-swagger-json.py index d6f53b51..d411ebf3 100644 --- a/scripts/fix-swagger-json.py +++ b/scripts/fix-swagger-json.py @@ -7,6 +7,20 @@ path = "internal/api/v1/docs/swagger.json" with open(path, "r") as f: data = json.load(f) +if isinstance(data["definitions"]["netip.Addr"], dict): + # MarshalText() + data["definitions"]["netip.Addr"] = { + "anyOf": [{ + "type": "string", + "format": "ipv4" + }, { + "type": "string", + "format": "ipv6" + }], + "x-nullable": False, + "x-omitempty": False + } + def set_non_nullable(data): if not isinstance(data, dict): return