swagger-api / swagger-api/swagger-codegen

Swift4: Add additional initializer for initializing model object with *only* required properties

Open
#8,852 0 comments 0 reactions 0 assignees View on GitHub

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

https://github.com/swagger-api/swagger-codegen/issues/6641

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.