model

package
v1.0.115 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2016 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package model contains the core logic of the code generation process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCode

func GenerateCode(goOutputDir, modelData string)

GenerateCode takes the objects loaded into memory in LoadAPIs and writes them out as go code.

Types

type API

type API struct {
	BaseURL     string      `json:"baseUrl"`
	Description string      `json:"description"`
	Entries     []APIEntry  `json:"entries"`
	Title       string      `json:"title"`
	Version     interface{} `json:"version"`
	Schema      string      `json:"$schema"`
	// contains filtered or unexported fields
}

API represents the HTTP interface of a TaskCluster service

func (*API) String

func (api *API) String() string

type APIDefinition

type APIDefinition struct {
	URL     string `json:"url"`
	Name    string `json:"name"`
	DocRoot string `json:"docroot"`
	Data    APIModel

	PackageName    string
	ExampleVarName string
	PackagePath    string
	SchemaURL      string
	// contains filtered or unexported fields
}

APIDefinition represents the definition of a REST API, comprising of the URL to the defintion of the API in json format, together with a URL to a json schema to validate the definition

func LoadAPIs

func LoadAPIs(apiManifestUrl, supplementaryDataFile string) []APIDefinition

LoadAPIs takes care of reading all json files and performing elementary processing of the data, such as assigning unique type names to entities which will be translated to go types.

Data is unmarshaled into objects (or instances of go types) and then postPopulate is called on the objects. This in turn triggers further reading of json files and unmarshalling where schemas refer to other schemas.

When LoadAPIs returns, all json schemas and sub schemas should have been read and unmarhsalled into go objects.

type APIEntry

type APIEntry struct {
	Args        []string   `json:"args"`
	Description string     `json:"description"`
	Input       string     `json:"input"`
	Method      string     `json:"method"`
	Name        string     `json:"name"`
	Query       []string   `json:"query"`
	Route       string     `json:"route"`
	Scopes      [][]string `json:"scopes"`
	Stability   string     `json:"stability"`
	Output      string     `json:"output"`
	Title       string     `json:"title"`
	Type        string     `json:"type"`

	MethodName string
	Parent     *API
}

func (*APIEntry) String

func (entry *APIEntry) String() string

type APIModel

type APIModel interface {
	String() string
	// contains filtered or unexported methods
}

type Exchange

type Exchange struct {
	Version        interface{}     `json:"version"`
	Title          string          `json:"title"`
	Description    string          `json:"description"`
	ExchangePrefix string          `json:"exchangePrefix"`
	Entries        []ExchangeEntry `json:"entries"`
	// contains filtered or unexported fields
}

func (*Exchange) String

func (exchange *Exchange) String() string

type ExchangeEntry

type ExchangeEntry struct {
	Type        string         `json:"type"`
	Exchange    string         `json:"exchange"`
	Name        string         `json:"name"`
	Title       string         `json:"title"`
	Description string         `json:"description"`
	RoutingKey  []RouteElement `json:"routingKey"`
	Schema      string         `json:"schema"`

	Parent  *Exchange
	Payload *JsonSubSchema
}

func (*ExchangeEntry) String

func (entry *ExchangeEntry) String() string

type JsonSubSchema

type JsonSubSchema jsonschema2go.JsonSubSchema

func (*JsonSubSchema) TypeDefinition

func (jsonSubSchema *JsonSubSchema) TypeDefinition(level int, extraPackages map[string]bool) (classDefinition, comment, typ string)

type RouteElement

type RouteElement struct {
	Name          string `json:"name"`
	Summary       string `json:"summary"`
	Constant      string `json:"constant"`
	MultipleWords bool   `json:"multipleWords"`
	Required      bool   `json:"required"`
}

func (*RouteElement) String

func (re *RouteElement) String() string

type SortedAPIDefs

type SortedAPIDefs []APIDefinition

func (SortedAPIDefs) Len

func (a SortedAPIDefs) Len() int

needed so that SortedAPIDefs can implement sort.Interface

func (SortedAPIDefs) Less

func (a SortedAPIDefs) Less(i, j int) bool

func (SortedAPIDefs) Swap

func (a SortedAPIDefs) Swap(i, j int)

Jump to

Keyboard shortcuts

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