Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6046
Closed
Open
Issue created Apr 24, 2020 by Administrator@rootContributor

[REQ][SWIFT5] Readonly properties on struct models

Created by: iliaskarim

Is your feature request related to a problem? Please describe.

Structs support immutability after initialization. Immutable data types, particularly value types like structs, encourage functional programming practices. By reducing shared mutable state inherit in objects with mutable properties, using immutable value types makes it less likely that UI appears out of sync with an application's data.

Describe the solution you'd like

Swift4/5 structs, when built without Objective-C compatibility, rather than declaring their properties with the var keyword, can use private(set) var keywords to make them only be mutated by the struct's initializer.

This solution could be enabled through an additional property that defaults to false.

Describe alternatives you've considered

The let keyword for properties on structs cannot be combined with default values. So, to keep the syntax consistent between properties that have default values and those that don't, use private(set) var instead.

Additional context

Assignee
Assign to
Time tracking