swagger

package
v1.1.384 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalPath added in v1.1.384

type AdditionalPath struct {
	// Name is the name to use for the generated path
	Name string
	// Path is the path to inject in the hierarchy
	Path string
	// GetPath allows the actual path used at runtime to be overridden
	GetPath string
	// FixedContent provides static content to render in place of making an API call
	FixedContent string
	// SubPathRegesx holds regex info for modifying subpath URLs
	SubPathRegex *RegexReplace
}

AdditionalPath provides metadata for additional paths to inject into the generated hierarchy

type Config

type Config struct {
	// Overrides is keyed on url
	Overrides map[string]PathOverride
	// AdditionalPaths contains extra paths to include in the generated hierarchy
	AdditionalPaths []AdditionalPath
	// SuppressAPIVersion true to prevent the api version querystring
	SuppressAPIVersion bool
}

Config handles configuration of url handling

type Path

type Path struct {
	Name                  string
	CondensedEndpointPath string
	FixedContent          string
	Endpoint              *endpoints.EndpointInfo // The logical endpoint. May be overridden for an operation
	Operations            PathOperations
	Children              []*Path
	SubPaths              []*Path
	SubPathRegex          *RegexReplace
}

Path represents a path that we want to consider emitting in code-gen. It is derived from

func MergeSwaggerDoc

func MergeSwaggerDoc(currentPaths []*Path, config *Config, doc *loads.Document, validateCapturedSegments bool) ([]*Path, error)

MergeSwaggerDoc merges api endpoints from the specified swagger doc into the Paths array

type PathOperation

type PathOperation struct {
	Permitted bool                    // true if the operation is permitted for the path
	Verb      string                  // Empty unless the Verb is overridden for the operation
	Endpoint  *endpoints.EndpointInfo // nil unless the endpoint is overridden for the operation
}

PathOperation represents an operation on the path (GET, PUT, ...)

type PathOperations

type PathOperations struct {
	Get    PathOperation
	Delete PathOperation
	Patch  PathOperation
	Post   PathOperation
	Put    PathOperation
}

PathOperations gives details on the operations for a resource

type PathOverride

type PathOverride struct {
	Path    string // actual url to use
	GetVerb string // Verb to use for logical GET requests
}

PathOverride captures Path and/or Verb overrides

type RegexReplace added in v1.1.384

type RegexReplace struct {
	Match   string
	Replace string
}

RegexReplace holds match and replacement info

type ResourceType

type ResourceType struct {
	Display        string
	Endpoint       *endpoints.EndpointInfo
	Verb           string
	DeleteEndpoint *endpoints.EndpointInfo
	PatchEndpoint  *endpoints.EndpointInfo
	PutEndpoint    *endpoints.EndpointInfo
	Children       []ResourceType // Children are auto-loaded (must be able to build the URL => no additional template URL values)
	SubResources   []ResourceType // SubResources are not auto-loaded (these come from the request to the endpoint)
	FixedContent   string
	SubPathRegex   *RegexReplace
	// contains filtered or unexported fields
}

ResourceType holds information about resources that can be displayed

func ConvertToSwaggerResourceTypes

func ConvertToSwaggerResourceTypes(paths []*Path) []ResourceType

ConvertToSwaggerResourceTypes converts the Path array to an array of SwaggerResourceTypes for use with the Swagger expander

func GetResourceTypeForURL added in v1.1.384

func GetResourceTypeForURL(ctx context.Context, url string, resourceTypes []ResourceType) *ResourceType

GetResourceTypeForURL Gets the resource type matching the url

func (ResourceType) GetSubResourceTypeForURL added in v1.1.384

func (r ResourceType) GetSubResourceTypeForURL(ctx context.Context, url string) *ResourceType

GetSubResourceTypeForURL gets the SubResource matching the URL

func (ResourceType) PerformSubPathReplace added in v1.1.384

func (r ResourceType) PerformSubPathReplace(url string) (string, error)

PerformSubPathReplace performs any configured SubPathRegex replacement

Jump to

Keyboard shortcuts

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