mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
tpl/openapi3: Wrap *kopenapi3.T
To make it easier to document.
This commit is contained in:
parent
b54de1bd9b
commit
87e898a17a
1 changed files with 8 additions and 3 deletions
|
@ -49,7 +49,12 @@ type Namespace struct {
|
||||||
deps *deps.Deps
|
deps *deps.Deps
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ns *Namespace) Unmarshal(r resource.UnmarshableResource) (*kopenapi3.T, error) {
|
// OpenAPIDocument represents an OpenAPI 3 document.
|
||||||
|
type OpenAPIDocument struct {
|
||||||
|
*kopenapi3.T
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ns *Namespace) Unmarshal(r resource.UnmarshableResource) (*OpenAPIDocument, error) {
|
||||||
key := r.Key()
|
key := r.Key()
|
||||||
if key == "" {
|
if key == "" {
|
||||||
return nil, errors.New("no Key set in Resource")
|
return nil, errors.New("no Key set in Resource")
|
||||||
|
@ -85,11 +90,11 @@ func (ns *Namespace) Unmarshal(r resource.UnmarshableResource) (*kopenapi3.T, er
|
||||||
|
|
||||||
err = kopenapi3.NewLoader().ResolveRefsIn(s, nil)
|
err = kopenapi3.NewLoader().ResolveRefsIn(s, nil)
|
||||||
|
|
||||||
return s, err
|
return &OpenAPIDocument{T: s}, err
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.(*kopenapi3.T), nil
|
return v.(*OpenAPIDocument), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue