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

useSwiftyPropertyNames and sortPropertiesAlphabetically ordering #174

Open
LePips opened this issue Dec 13, 2022 · 1 comment · May be fixed by #175
Open

useSwiftyPropertyNames and sortPropertiesAlphabetically ordering #174

LePips opened this issue Dec 13, 2022 · 1 comment · May be fixed by #175
Labels
bug Something isn't working

Comments

@LePips
Copy link
Contributor

LePips commented Dec 13, 2022

Using useSwiftyPropertyNames: true and entities.sortPropertiesAlphabetically: true, the is- conversion is happening after the alphabetical sorting.

Example schema:

// ...
components:
  schemas:
    Pet:
      title: A pet title
      description: A pet description
      type: object
      required:
        - id
      properties:
        id:
          type: string
        likesMeat:
          type: boolean
        allergic:
          type: boolean

Generates the following:

public struct Pet: Codable {
    public var isAllergic: Bool?
    public var id: String
    public var isLikesMeat: Bool?

    // ...
}

It would be much more preferable if properties were properly sorted:

public struct Pet: Codable {
    public var id: String
    public var isAllergic: Bool?
    public var isLikesMeat: Bool?

    // ...
}

Additionally, it would probably be beneficial for an exclude list for useSwiftyPropertyNames as some property conversions may not be grammatically preferable, like in the above example.

@liamnichols liamnichols added the bug Something isn't working label Dec 13, 2022
@liamnichols
Copy link
Member

Thanks for raising! I agree, it looks like a bug. Probably related to those bigger issues we have around consistently applying transformations to the data that is parsed out of the schema.

I'm not sure how the implementation works currently, but I agree that the alphabetical sort should happen after any renaming 👍

@LePips LePips linked a pull request Dec 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants