Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultJSONIndent = " " DefaultContentType = "application/json" )
Variables ¶
This section is empty.
Functions ¶
func WithContentType ¶
func WithContentType(contentType string) func(*endpointsConfig)
func WithIndent ¶
func WithIndent(indent string) func(*endpointsConfig)
Types ¶
type Endpoint ¶
type Endpoint struct {
// Summary of the endpoint.
Summary string
// Description of the endpoint.
Description string
// Method HTTP method.
Method string
// Status HTTP status of the first response.
Status string
// Path with param tags as defined.
Path string
// Path with param tags replaced by examples.
PathWithParams string
// RequestBody request body example, if any.
RequestBody string
// Response JSON example of the first defined response.
Response string
// ResponseDescription description of the first response.
ResponseDescription string
}
type Enum ¶
type Enum struct {
// Title of the enum, includes the field name an the resource name.
Title string
// Resource resource name the enum belongs to.
Resource string
// Options all the available options for the enumeration.
Options []Option
}
func Enumerations ¶
func Enumerations(spec *openapiparser.Spec) (enums []Enum)
Enumerations returns a list of enumerations in a spec file.
type Resource ¶
type Resource struct {
// Name name of the resource.
Name string
// JSON a rendered example of the resource.
JSON string
// Description the description of the resource.
Description string
// Fields the fields of the resource.
Fields []ResourceField
}
Resource is a different representation of a defined schema
func ResourcesWithJSONIndent ¶
func ResourcesWithJSONIndent(spec *openapiparser.Spec, indent string) (resources []Resource, err error)
ResourcesWithJSONIndent returns a list of resource defined in a spec file with custom indentation for the JSON examples.
type ResourceField ¶
type ResourceField struct {
// Status a flatten key for the resource filed
// Examples:
// - foo
// - foo.bar
// - foo.#.bar
Key string
// Type JSON type of the field.
Type string
// Link if not empty holds the name of a named resource
// that was hold the information for this field.
Link string
// Enumeration holds the title of the enumeration.
Enumeration string
// Description the resource description.
Description string
}
type Tag ¶
type Tag struct {
// Tag name
Name string
// Endpoint list of endpoints with the same tag.
Endpoint []Endpoint
}
func EndpointsByTag ¶
func EndpointsByTag(spec *openapiparser.Spec, opts ...func(*endpointsConfig)) (tags []Tag, err error)
PathTags builds a lis of tags that contain the paths belonging to them respecting the order in which they were defined in the spec file.
The last tag will be "Default" and contain all the endpoints that have no tags (if any).
If an endpoint has more than one tag defined only the first one will be used.
Click to show internal directories.
Click to hide internal directories.