doc

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 4 Imported by: 0

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 Option

type Option struct {
	// Status holds the option value.
	Value string
	// Description is only filled if there was a custom "x-enum" entry in the spec file.
	Description string
}

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 Resources

func Resources(spec *openapiparser.Spec) (resources []Resource, err error)

Resources returns a list of resource defined in a spec file.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL