Skip to content

Commit 1b981d7

Browse files
committed
openapi3gen: Fix issue with separate component generated for time.Time fields, when ExportComponentSchemas opt provided
1 parent 72fb819 commit 1b981d7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

openapi3gen/openapi3gen.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ func (g *Generator) generateWithoutSaving(parents []*theTypeInfo, t reflect.Type
429429

430430
// For structs we add the schemas to the component schemas
431431
if len(parents) > 1 || g.opts.exportComponentSchemas.ExportTopLevelSchema {
432+
// If struct is a time.Time instance, separate component shouldn't be generated
433+
if t == timeType {
434+
return openapi3.NewSchemaRef(t.Name(), schema), nil
435+
}
436+
432437
typeName := g.generateTypeName(t)
433438

434439
g.componentSchemaRefs[typeName] = struct{}{}

0 commit comments

Comments
 (0)