Closed podhmo closed 3 years ago
the simple reproducible example
package main
import (
"time"
reflectopenapi "github.com/podhmo/reflect-openapi"
)
type Media struct {
Name string `json:"name"`
CTime time.Time `json:"ctime"`
}
func main() {
var c reflectopenapi.Config
c.EmitDoc(func(m *reflectopenapi.Manager) {
op := m.Visitor.VisitFunc(ListMedia)
m.Doc.AddOperation("/Media/", "GET", op)
})
}
func ListMedia() []*Media {
return nil
}
generated doc
{
"components": {
"schemas": {
"Media": {
"properties": {
"ctime": {
"$ref": "#/components/schemas/Time"
},
"name": {
"type": "string"
}
},
"type": "object"
},
"Time": {
"format": "date-time",
"type": "string"
}
}
},
"info": {
"description": "-",
"title": "Sample API",
"version": "0.0.0"
},
"openapi": "3.0.0",
"paths": {
"/Media/": {
"get": {
"operationId": "main.ListMedia",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/Media"
},
"type": "array"
}
}
},
"description": ""
},
"default": {
"description": ""
}
}
}
}
},
"servers": [
{
"url": "http://localhost:8888",
"description": "local development server"
}
]
}
fixed already.
for #39
time.Time is registered, but generated openapi doc is not included as schema.