wadlext

package
v0.0.0-...-feedf35 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: CC0-1.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateInitConfig

func GenerateInitConfig(clusters []Cluster, wadlPath, base, output string, depth int) string

GenerateInitConfig returns YAML text for a starter config file with all clusters listed under an "# unassigned" stub, ready for the user to move into named groups.

func ValidateConfig

func ValidateConfig(cfg *SplitConfig, allClusters []Cluster) error

ValidateConfig checks that:

  • every cluster key referenced in the config exists in allClusters
  • no cluster key appears in more than one group
  • every cluster in allClusters is assigned to exactly one group

Returns a non-nil error listing all problems found.

Types

type Cluster

type Cluster struct {
	// Name is the distinguishing segment (or "core" for shallow paths).
	Name      string
	Resources []Resource
}

Cluster groups resources that share a common sub-path key.

func (*Cluster) Paths

func (c *Cluster) Paths() []string

Paths returns the samplePath of every resource in this cluster.

type Doc

type Doc struct {
	Title string `xml:"title,attr"`
	Text  string `xml:",chardata"`
}

Doc represents a WADL doc element

type Extractor

type Extractor struct {
	// contains filtered or unexported fields
}

Extractor extracts WADL resources by path prefix

func NewExtractor

func NewExtractor(wadlPath string) (*Extractor, error)

NewExtractor creates a new WADL extractor from a file

func NewExtractorFromReader

func NewExtractorFromReader(r io.Reader) (*Extractor, error)

NewExtractorFromReader creates a new WADL extractor from a reader

func (*Extractor) Extract

func (e *Extractor) Extract(pathPrefix string) *WADLApplication

Extract extracts all resources starting with the given path prefix. For multiple prefixes use ExtractMany.

func (*Extractor) ExtractCluster

func (e *Extractor) ExtractCluster(c Cluster) *WADLApplication

ExtractCluster builds a WADLApplication from the resources in a single Cluster.

func (*Extractor) ExtractClusters

func (e *Extractor) ExtractClusters(clusters []Cluster) *WADLApplication

ExtractClusters builds a WADLApplication combining resources from multiple clusters. Resources are returned in WADL document order.

func (*Extractor) ExtractMany

func (e *Extractor) ExtractMany(prefixes []string) *WADLApplication

ExtractMany extracts all resources whose SamplePath starts with any of the given prefixes. Resources are returned in WADL document order.

func (*Extractor) Save

func (e *Extractor) Save(app *WADLApplication, outputPath string) error

Save writes the extracted WADL to a file preserving raw resource XML

func (*Extractor) SuggestClusters

func (e *Extractor) SuggestClusters(prefix string, depth int) []Cluster

SuggestClusters analyses all resources whose SamplePath starts with prefix and groups them by the distinguishing segment at the given depth. The returned slice is sorted by cluster name, with "core" first.

type Grammars

type Grammars struct {
	Includes []Include `xml:"include"`
}

Grammars represents WADL grammars section

type GroupConfig

type GroupConfig struct {
	Clusters []string `yaml:"clusters"`
}

GroupConfig describes one logical service group within a SplitConfig.

type Include

type Include struct {
	Href string `xml:"href,attr"`
}

Include represents a schema include

type Method

type Method struct {
	XMLName  xml.Name   `xml:"method"`
	ID       string     `xml:"id,attr"`
	Name     string     `xml:"name,attr"`
	Request  *Request   `xml:"request,omitempty"`
	Response []Response `xml:"response"`
	Attrs    []xml.Attr `xml:",any,attr"`
}

Method represents a WADL method element

type Param

type Param struct {
	XMLName  xml.Name   `xml:"param"`
	Name     string     `xml:"name,attr"`
	Style    string     `xml:"style,attr"`
	Type     string     `xml:"type,attr"`
	Required string     `xml:"required,attr"`
	Doc      *Doc       `xml:"doc,omitempty"`
	Attrs    []xml.Attr `xml:",any,attr"`
}

Param represents a WADL param element

type Representation

type Representation struct {
	XMLName   xml.Name   `xml:"representation"`
	MediaType string     `xml:"mediaType,attr"`
	Element   string     `xml:"element,attr"`
	Attrs     []xml.Attr `xml:",any,attr"`
}

Representation represents a WADL representation element

type Request

type Request struct {
	XMLName xml.Name         `xml:"request"`
	Params  []Param          `xml:"param"`
	Reps    []Representation `xml:"representation"`
}

Request represents a WADL request element

type Resource

type Resource struct {
	XMLName     xml.Name      `xml:"resource"`
	ID          string        `xml:"id,attr"`
	SamplePath  string        `xml:"samplePath,attr"`
	Doc         *Doc          `xml:"doc,omitempty"`
	Methods     []Method      `xml:"method"`
	SampleParam []SampleParam `xml:"sampleParam"`
	Attrs       []xml.Attr    `xml:",any,attr"`
	RawXML      string        `xml:"-"`
}

Resource represents a WADL resource element

func (*Resource) UnmarshalXML

func (r *Resource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML custom unmarshaler to handle namespaced attributes

type Resources

type Resources struct {
	SampleBase string     `xml:"sampleBase,attr"`
	Resources  []Resource `xml:"resource"`
	Attrs      []xml.Attr `xml:",any,attr"`
}

Resources represents WADL resources section

type Response

type Response struct {
	XMLName xml.Name         `xml:"response"`
	Status  string           `xml:"status,attr"`
	Params  []Param          `xml:"param"`
	Reps    []Representation `xml:"representation"`
	Attrs   []xml.Attr       `xml:",any,attr"`
}

Response represents a WADL response element

type SampleParam

type SampleParam struct {
	XMLName xml.Name   `xml:"sampleParam"`
	Name    string     `xml:"name,attr"`
	Style   string     `xml:"style,attr"`
	Type    string     `xml:"type,attr"`
	Attrs   []xml.Attr `xml:",any,attr"`
}

SampleParam represents a WADL sample parameter

type SplitConfig

type SplitConfig struct {
	WADL   string                 `yaml:"wadl"`
	Base   string                 `yaml:"base"`
	Depth  int                    `yaml:"depth"`
	Output string                 `yaml:"output"`
	Groups map[string]GroupConfig `yaml:"groups"`
}

SplitConfig is the top-level structure of a wadl-extract grouping config file.

func LoadSplitConfig

func LoadSplitConfig(path string) (*SplitConfig, error)

LoadSplitConfig reads and unmarshals a YAML config file.

type WADLApplication

type WADLApplication struct {
	XMLName   xml.Name   `xml:"application"`
	Doc       *Doc       `xml:"doc,omitempty"`
	Grammars  *Grammars  `xml:"grammars,omitempty"`
	Resources *Resources `xml:"resources,omitempty"`
	Attrs     []xml.Attr `xml:",any,attr"`
}

WADLApplication represents the root WADL element

func (*WADLApplication) GetResourceCount

func (app *WADLApplication) GetResourceCount() int

GetResourceCount returns the number of resources in the application

func (*WADLApplication) GetResourcePaths

func (app *WADLApplication) GetResourcePaths() []string

GetResourcePaths returns all resource paths in the application

Jump to

Keyboard shortcuts

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