Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/test/issues/issue609/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# yaml-language-server: $schema=../../../../configuration-schema.json
package: issue609
generate:
models: true
output: issue609.gen.go
output-options:
skip-prune: true
3 changes: 3 additions & 0 deletions internal/test/issues/issue609/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package issue609

//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml openapi.yaml
9 changes: 9 additions & 0 deletions internal/test/issues/issue609/issue609.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions internal/test/issues/issue609/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: "Referencing an optional field, which has no information about the type it is will generate an `interface{}`, without the 'optional pointer'"
paths:
components:
schemas:
ResponseBody:
type: object
properties:
unknown: {}
2 changes: 2 additions & 0 deletions pkg/codegen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ func GenerateGoSchema(sref *openapi3.SchemaRef, path []string) (Schema, error) {
// If we don't even have the object designator, we're a completely
// generic type.
outType = "interface{}"
// this should never have an "optional pointer", as it doesn't make sense to be a `*interface{}`
outSchema.SkipOptionalPointer = true
}
outSchema.GoType = outType
outSchema.DefineViaAlias = true
Expand Down