OpenAPITools / OpenAPITools/openapi-generator

[BUG][SWIFT4] Inherited enumerations are not being generated correctly

Open
#2,370 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Whenever a definition is inheriting enumeration fields (using allOf), these end up being generated without any options.

public enum Status: String, Codable {
}

Those same enumerations are being generated correctly on the original definition.

Our spec is still using swagger 2.0.

openapi-generator version

Happening on v3.3.4. Was using swagger-codegen before and did not have this issue.

OpenAPI declaration file content or url
ParentObject:
    type: object
    required:
      - id
      - status
    properties:
      id:
        type: string
      status:
        type: string
        enum:
          - generate
          - activate
          - suspend
          - refund
          - expire
          - burn
  NamedChildObject:
    allOf:
      - $ref: '#/definitions/ParentObject'
      - type: object
        properties:
          name:
          type: string

Using the example above, NamedObject will look like:

public struct NamedChildObject: Codable {

    public enum Status: String, Codable {
    }
    public var _id: String
    public var status: Status

    public init(_id: String, status: Status) {
        self._id = _id
        self.status = status
    }

    public enum CodingKeys: String, CodingKey { 
        case _id = "id"
        case status
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied Swagger 2.0 declaration using openapi-generator v3.3.4, then inspect Swift 4 generation for inherited properties handled through allOf. Done when NamedChildObject.Status contains the inherited enum options while the original definition continues to generate correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.