OpenAPITools / OpenAPITools/openapi-generator
[BUG][Go][Client] Empty object generates compilation failure
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided openapi-generator command with the minimal swagger.yaml specification and inspect the generated Go client's FooPostOpts model. Trace how an empty object definition is represented for the optional body parameter, then verify that the generated client compiles and uses a valid map type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100