-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexternal_docs.go
32 lines (26 loc) · 1.03 KB
/
external_docs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package openapi
import (
"net/url"
"github.com/MarkRosemaker/errpath"
)
// ExternalDocs allows referencing an external resource for extended documentation.
// ([Specification])
//
// [Specification]: https://spec.openapis.org/oas/v3.1.0#external-documentation-object
type ExternalDocs struct {
// A description of the target documentation. CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// REQUIRED. The URL for the target documentation. This MUST be in the form of a URL.
URL *url.URL `json:"url,omitempty" yaml:"url,omitempty"`
// This object MAY be extended with Specification Extensions.
Extensions Extensions `json:",inline" yaml:",inline"`
}
// Validate checks the external documentation for consistency.
func (ed *ExternalDocs) Validate() error {
if ed.URL == nil {
return &errpath.ErrField{Field: "url", Err: &errpath.ErrRequired{}}
}
// assume that the scheme is https and add it if it is missing
fixScheme(ed.URL)
return nil
}