Skip to content

Generated models and types should follow Swift conventions #107

Closed as not planned
@PadraigK

Description

@PadraigK

The casing of names in the generated code should match normal Swift coding standards, e.g. properties should be camelCase and types should be PascalCase.

From reading the principles, I understand that the generator wants to be true to whatever is in the spec and the general guidance is that we should build tools around the generator to customize things. I also understand that implementing this in the generator could lead to naming collisions in certain cases. However, without this feature, it would be hard to justify migrating a code base from a generator that does camelCase names to this one.

Some things I've considered:

  • Preprocessing the spec: This won’t work, since the models need to serialize back to the exact original in the spec or generated JSON will be wrong and the server side would fail.
  • Change the spec: This would be too disruptive. It would force the clients using other languages to adopt Swift coding standards. Many users don't control their specs.
  • Writing custom models and mapping everything from the server into them: This would also be a large amount of busy-work and a maintenance headache, as well as a runtime cost.

Ideally this would be a setting or even the default. The generator could detect collisions and throw an obvious error. I'm also open to trying any work arounds that I haven't considered here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions