You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I'm using this generator to generate Swift5 code for my frontend. The generator creates a NullEnum type that is unused and produces the Swift compiler error 'NullEnum' declares raw type 'String', but does not conform to RawRepresentable and conformance could not be synthesized.
For context, I generate my YAMLs using drf-spectacular, which I'm using for the API on my server. drf-spectacular creates the NullEnum type and includes it on all enum fields where null=True is set in the Django model (see the example below for clarification).
openapi-generator version
I'm using openapi-generator-cli 7.11.0, commit hash a7240ee.
OpenAPI declaration file content or url
Here's the part of the YAML file that produces the null enum. In the Swift generated code, any enum that can be null will just be marked as optional—the NullEnum type is never used and does not need to be generated.
NullEnum:
enum:
- null
Generation Details
I typically use the generator installed with Homebrew, but using the latest OpenAPI Generator version (downloaded using the "build the project locally" instructions here reproduced the error).
Steps to reproduce
Create an OpenAPI.yaml file using OpenAPI 3.0.3.
Create a file name OpenAPI.yaml with the contents pasted below. I am using drf-spectacular to generate my schemas, and there are several instances where I have this pattern of the three enums (some enum, BlankEnum, and NullEnum).
Run openapi-generator generate -i path/to/yaml/OpenAPI.yaml -g swift5 -o /path/to/output/TestAPI in the command line.
Looking at the generated code, the NullEnum type is defined but never used. Here is the definition you should see:
publicenumNullEnum:String,Codable,CaseIterable{}
This type generates the Swift compiler error, 'NullEnum' declares raw type 'String', but does not conform to RawRepresentable and conformance could not be synthesized.
I can solve the error by commenting this code out or deleting the file, but it seems like we don't need to generate NullEnum at all.
Related issues/PRs
I couldn't find a similar issue with the Swift5 generator.
Suggest a fix
Not 100% sure where this NullEnum enum generation occurs, but NullEnum may not be needed for Swift code to function. I just comment it out every time I generate the schema. These errors also go away if NullEnum does not declare raw type String or conform to Codable. Here's an updated NullEnum definition that will compile:
publicenumNullEnum:CaseIterable{}
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
I'm using this generator to generate Swift5 code for my frontend. The generator creates a
NullEnum
type that is unused and produces the Swift compiler error'NullEnum' declares raw type 'String', but does not conform to RawRepresentable and conformance could not be synthesized
.For context, I generate my YAMLs using drf-spectacular, which I'm using for the API on my server. drf-spectacular creates the
NullEnum
type and includes it on all enum fields wherenull=True
is set in the Django model (see the example below for clarification).openapi-generator version
I'm using openapi-generator-cli 7.11.0, commit hash a7240ee.
OpenAPI declaration file content or url
Here's the part of the YAML file that produces the null enum. In the Swift generated code, any enum that can be null will just be marked as optional—the
NullEnum
type is never used and does not need to be generated.Generation Details
I typically use the generator installed with Homebrew, but using the latest OpenAPI Generator version (downloaded using the "build the project locally" instructions here reproduced the error).
Steps to reproduce
BlankEnum
, andNullEnum
).openapi-generator generate -i path/to/yaml/OpenAPI.yaml -g swift5 -o /path/to/output/TestAPI
in the command line.Looking at the generated code, the
NullEnum
type is defined but never used. Here is the definition you should see:This type generates the Swift compiler error,
'NullEnum' declares raw type 'String', but does not conform to RawRepresentable and conformance could not be synthesized
.I can solve the error by commenting this code out or deleting the file, but it seems like we don't need to generate
NullEnum
at all.Related issues/PRs
I couldn't find a similar issue with the Swift5 generator.
Suggest a fix
Not 100% sure where this
NullEnum
enum generation occurs, butNullEnum
may not be needed for Swift code to function. I just comment it out every time I generate the schema. These errors also go away ifNullEnum
does not declare raw typeString
or conform toCodable
. Here's an updatedNullEnum
definition that will compile:The text was updated successfully, but these errors were encountered: