swagger-api / swagger-api/swagger-codegen

[Swift4] swagger-codegen 3.0.8 and lower create swift models that are incorrectly formatted without line breaks

Open
#9,348 2 comments 3 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

After enums in a generated model struct there is no line break. This makes the swift compiler throw an error.

Swagger-codegen version

Preoduced issue on 3.0.5 and verified on
swagger-codegen-cli-3.0.8-20190329.080540-4

{
  "title": "ParBlock",
  "type": "object",
  "properties": {
    "type": {
      "title": "Type",
      "default": "seq",
      "enum": [
        "audio",
        "video",
        "sleep"
      ],
      "type": "string"
    },
    "length": {
      "title": "Length",
      "default": 0,
      "type": "integer"
    },
    "name": {
      "title": "Name",
      "default": "",
      "type": "string"
    },
    "par_blocks": {
      "title": "Par_Blocks",
      "default": [
        
      ],
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/Block"
      }
    }
  }
}
Swagger declaration file content or url
Command line used for generation

swagger-codegen generate -i openapi.json -l swift4 -o .

Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

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

Reproduce the issue with the supplied schema using the swagger-codegen generate -i openapi.json -l swift4 -o . command. Inspect the generated Swift model around the enum and verify that the output has the required line breaks and compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.