Skip to content

Commit

Permalink
tpl/openapi3: Wrap *kopenapi3.T
Browse files Browse the repository at this point in the history
To make it easier to document.
  • Loading branch information
bep committed Dec 14, 2022
1 parent b54de1b commit 87e898a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tpl/openapi/openapi3/openapi3.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ type Namespace struct {
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()
if key == "" {
return nil, errors.New("no Key set in Resource")
Expand Down Expand Up @@ -85,11 +90,11 @@ func (ns *Namespace) Unmarshal(r resource.UnmarshableResource) (*kopenapi3.T, er

err = kopenapi3.NewLoader().ResolveRefsIn(s, nil)

return s, err
return &OpenAPIDocument{T: s}, err
})
if err != nil {
return nil, err
}

return v.(*kopenapi3.T), nil
return v.(*OpenAPIDocument), nil
}

0 comments on commit 87e898a

Please sign in to comment.