Skip to content

[Swift4] Model object cannot handle recursion #7788

Closed
@Zexbe

Description

@Zexbe
Description

Swagger-codegen fails to handle recursion after switching to structs.

Swagger-codegen version

2.4.0

Swagger declaration file content or url
swagger: "2.0"
info:
  title: "Example"
  version: "1.0.0"
host: "store.example.com"
basePath: "/v2"
schemes:
- "http"
paths:
  /category/{categoryId}:
    get:
      summary: "Find category by ID"
      operationId: "getCategoryById"
      produces:
      - "application/json"
      parameters:
      - name: "categoryId"
        in: "path"
        description: "ID of category to return"
        required: true
        type: "integer"
        format: "int64"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/Category"
        400:
          description: "Invalid ID supplied"
        404:
          description: "Category not found"
definitions:
  Category:
    type: "object"
    properties:
      id:
        type: "integer"
        format: "int64"
      name:
        type: "string"
      parent:
        $ref: "#/definitions/Category"
      children:
        type: array
        items:
          $ref: "#/definitions/Category"
    xml:
      name: "Category"
Command line used for generation

-l swift4

Steps to reproduce

Generate client with swagger provided.
Add client to xcode project
Try to compile.

Related issues/PRs

#4126

Suggest a fix/enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions