Skip to content

"swagger generate cli" generates code that does not compile  #2650

@perelman92

Description

@perelman92

Problem statement

Running swagger generate cli generates code which cannot be compiled.

cli/runner_group_model.go:52:48: cannot use m (type *models.RunnerGroup) as type *models.Runner in argument to retrieveRunnerGroupNameFlags

cli/runner_model.go:27:6: registerRunnerGroupName redeclared in this block
       cli/runner_group_model.go:27:79: previous declaration

cli/runner_model.go:52:53: cannot use m (type *models.Runner) as type *models.RunnerGroup in argument to retrieveRunnerGroupNameFlags

cli/runner_model.go:61:6: retrieveRunnerGroupNameFlags redeclared in this block
        cli/runner_group_model.go:61:115: previous declaration

Swagger specification

swagger: "2.0"
info:
  contact:
    email: support@swagger.com
    name: API Support
    url: https://swagger.com
  title: My API
  version: "1.0"
host: swagger.com:80
basePath: /api/v1
paths:
  /api/runner:
    get:
      consumes:
        - application/json
      operationId: Get Runner
      produces:
        - application/json
      responses:
        "200":
          description: ok
          schema:
            $ref: '#/definitions/Runner'
      tags:
        - Runner
definitions:
  Runner:
    properties:
      group_name:
        type: string
    type: object
  RunnerGroup:
    properties:
      name:
        description: Name should be unique per tenant
        type: string
    type: object

Steps to reproduce

Use the swagger above.

$ swagger generate cli -f swagger.yaml
$ go build cmd/cli/main.go

Environment

swagger version: v0.28.0
go version: go1.17.1
OS: darwin/amd64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions