Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lopesmcc opened this issue Mar 12, 2019 · 1 comment
Open

Comments

@lopesmcc
Copy link
Contributor

lopesmcc commented Mar 12, 2019

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
    }
}
@lopesmcc
Copy link
Contributor Author

lopesmcc commented Mar 12, 2019

Seems to me that at DefaultCodegen.java:312, we should be iterating through the model allVars, and not only vars. This way, it would generate the enumVars metadata even for inherited data.

Not sure what kind of impact this would have for other generators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant