@@ -91,6 +91,9 @@ def extract_hash(schema):
9191 prop_hash_mapping [prop_name ].add (prop_enum_cleaned_hash )
9292 hash_name_mapping [prop_enum_cleaned_hash ].add ((component_name , prop_name ))
9393
94+ # get the suffix to be used for enums from settings
95+ enum_suffix = spectacular_settings .ENUM_SUFFIX
96+
9497 # traverse all enum properties and generate a name for the choice set. naming collisions
9598 # are resolved and a warning is emitted. giving a choice set multiple names is technically
9699 # correct but potentially unwanted. also emit a warning there to make the user aware.
@@ -101,13 +104,17 @@ def extract_hash(schema):
101104 enum_name = overrides [prop_hash ]
102105 elif len (prop_hash_set ) == 1 :
103106 # prop_name has been used exclusively for one choice set (best case)
104- enum_name = f"{ camelize (prop_name )} Enum "
107+ enum_name = f"{ camelize (prop_name )} { enum_suffix } "
105108 elif len (hash_name_mapping [prop_hash ]) == 1 :
106109 # prop_name has multiple choice sets, but each one limited to one component only
107110 component_name , _ = next (iter (hash_name_mapping [prop_hash ]))
108- enum_name = f"{ camelize (component_name )} { camelize (prop_name )} Enum"
111+ enum_name = (
112+ f"{ camelize (component_name )} { camelize (prop_name )} { enum_suffix } "
113+ )
109114 else :
110- enum_name = f"{ camelize (prop_name )} { prop_hash [:3 ].capitalize ()} Enum"
115+ enum_name = (
116+ f"{ camelize (prop_name )} { prop_hash [:3 ].capitalize ()} { enum_suffix } "
117+ )
111118 warn (
112119 f"enum naming encountered a non-optimally resolvable collision for fields "
113120 f'named "{ prop_name } ". The same name has been used for multiple choice sets '
@@ -170,16 +177,22 @@ def extract_hash(schema):
170177 if spectacular_settings .ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE :
171178 if "" in prop_enum_original_list :
172179 components .append (
173- create_enum_component ("BlankEnum" , schema = {"enum" : ["" ]})
180+ create_enum_component (
181+ f"Blank{ enum_suffix } " , schema = {"enum" : ["" ]}
182+ )
174183 )
175184 if None in prop_enum_original_list :
176185 if spectacular_settings .OAS_VERSION .startswith ("3.1" ):
177186 components .append (
178- create_enum_component ("NullEnum" , schema = {"type" : "null" })
187+ create_enum_component (
188+ f"Null{ enum_suffix } " , schema = {"type" : "null" }
189+ )
179190 )
180191 else :
181192 components .append (
182- create_enum_component ("NullEnum" , schema = {"enum" : [None ]})
193+ create_enum_component (
194+ f"Null{ enum_suffix } " , schema = {"enum" : [None ]}
195+ )
183196 )
184197
185198 # undo OAS 3.1 type list NULL construction as we cover this in a separate component already
0 commit comments