swagger-api / swagger-api/swagger-codegen
Swift4: Add additional initializer for initializing model object with *only* required properties
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
In a previous feature, you added init() methods that include all properties declared in the schema. My request is to provide an option for an init() method with only the required properties from the schema.
Swagger-codegen version
3.0.2
Swagger declaration file content or url
Foo:
required:
- id
properties:
id: # the init() function would only have this property
type: string
color:
type: string
Related issues/PRs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the Swift4 generator turns the schema's required properties into model initializers, then identify where an option for a required-only initializer would belong. Use the Foo example with required id and optional color as the acceptance case: generated models should offer an initializer taking id without requiring color.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100