From c08dcccd9b4bf3b7e98cfad33a12f074f6d9b578 Mon Sep 17 00:00:00 2001 From: Michael Helmling Date: Fri, 26 Aug 2022 15:23:34 +0200 Subject: [PATCH] feat: allow enums in header parameters (the currently supported) enums are int and string only, there's no reason not to allow them in headers (which is actually used in the wild). --- openapi_python_client/parser/properties/enum_property.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openapi_python_client/parser/properties/enum_property.py b/openapi_python_client/parser/properties/enum_property.py index fe704eefd..39b89a2bc 100644 --- a/openapi_python_client/parser/properties/enum_property.py +++ b/openapi_python_client/parser/properties/enum_property.py @@ -4,6 +4,7 @@ import attr +from ... import schema as oai from ... import utils from .property import Property from .schemas import Class @@ -22,6 +23,13 @@ class EnumProperty(Property): template: ClassVar[str] = "enum_property.py.jinja" + _allowed_locations: ClassVar[Set[oai.ParameterLocation]] = { + oai.ParameterLocation.QUERY, + oai.ParameterLocation.PATH, + oai.ParameterLocation.COOKIE, + oai.ParameterLocation.HEADER, + } + def get_base_type_string(self) -> str: return self.class_info.name