swagger-api / swagger-api/swagger-codegen

Swift model generate problem, if $ref in model, $ref is ignored.

Open
#12,184 1 comment 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

"AdventuresQuery": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EntitySearchQuery"
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "all": {
                "type": "boolean"
              },
              "recommended": {
                "type": "boolean"
              },
              "fields": {
                "$ref": "#/components/schemas/AdventuresQueryFields"
              }
            }
          }
        ]
      },

In swift generator you get this code

public struct AdventuresQuery: Codable {

    public var all: Bool?
    public var recommended: Bool?
    public var fields: AdventuresQueryFields?

    public init(all: Bool? = nil, recommended: Bool? = nil, fields: AdventuresQueryFields? = nil) {
        self.all = all
        self.recommended = recommended
        self.fields = fields
    }


}

as you can see EntitySearchQuery is ignored.

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 reproducing the Swift generator output with the provided AdventuresQuery schema, then trace the Swift model-generation path handling the allOf $ref to EntitySearchQuery. Done means the generated AdventuresQuery preserves the EntitySearchQuery fields or relationship instead of ignoring that reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.