Version: v1.2.132559162 Latest Latest

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

Go to latest
Published: Jun 11, 2020 License: MIT Imports: 9 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


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
	// DeletePath allows a delete url to be specified
	DeletePath 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 GetPathsFromSwagger added in v1.1.524

func GetPathsFromSwagger(doc *loads.Document, config *Config, pathPrefix string) ([]Path, error)

GetPathsFromSwagger returns the mapped Paths from the document

func MergeSwaggerDoc

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

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

func MergeSwaggerPaths added in v1.1.524

func MergeSwaggerPaths(currentPaths []*Path, config *Config, newPaths []Path, validateCapturedSegments bool, pathPrefix string) ([]*Path, error)

MergeSwaggerPaths merges api endpoints into the currentPaths 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
	RewritePath bool   // rewrite the path in generated code. Only advised to address case issues or inconsistent match segment names
	PutPath     string // Force the PUT endpoint to be output or override it
	DeletePath  string // Force the PUT endpoint to be output or override it

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