Skip to content

[BUG][Go][Client] Empty object generates compilation failure #3829

@qmuntal

Description

@qmuntal

Version
4.1.1

Command line used for generation
openapi-generator generate -i swagger.yaml -g go-o ./

Spec

swagger: "2.0"
info: 
  title: Foo
  version: v1
paths: 
  /foo: 
    post:
      operationId: fooPost
      parameters: 
        - 
          in: body
          name: body
          required: false
          schema: 
            $ref: "#/definitions/Foo"
      responses: 
        200: 
          description: "successful operation"
definitions: 
  Foo: 
    type: object

Description
Generated Foo model is:

type FooPostOpts struct {
	Body optional.Map[string]interface{}
}

which does not compile as optional.Map does not exist.
I would expect this model definition instead:

type FooPostOpts struct {
	Body map[string]interface{}
}

I can reproduce this issue with any object without properties.

cc @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09) @bkabrda (2019/07)
@wing328

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