Documentation ¶
Overview ¶
Package disco represents Google API discovery documents.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
OAuth2Scopes []Scope
}
Auth represents the auth section of a discovery document. Only OAuth2 information is retained.
func (*Auth) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Document ¶
type Document struct { ID string `json:"id"` Name string `json:"name"` Version string `json:"version"` Title string `json:"title"` RootURL string `json:"rootUrl"` MTLSRootURL string `json:"mtlsRootUrl"` ServicePath string `json:"servicePath"` BasePath string `json:"basePath"` DocumentationLink string `json:"documentationLink"` Auth Auth `json:"auth"` Features []string `json:"features"` Methods MethodList `json:"methods"` Schemas map[string]*Schema `json:"schemas"` Resources ResourceList `json:"resources"` }
A Document is an API discovery document.
func NewDocument ¶
NewDocument unmarshals the bytes into a Document. It also validates the document to make sure it is error-free.
type Kind ¶
type Kind int
Kind classifies a Schema.
const ( // SimpleKind is the category for any JSON Schema that maps to a // primitive Go type: strings, numbers, booleans, and "any" (since it // maps to interface{}). SimpleKind Kind = iota // StructKind is the category for a JSON Schema that declares a JSON // object without any additional (arbitrary) properties. StructKind // MapKind is the category for a JSON Schema that declares a JSON // object with additional (arbitrary) properties that have a non-"any" // schema type. MapKind // AnyStructKind is the category for a JSON Schema that declares a // JSON object with additional (arbitrary) properties that can be any // type. AnyStructKind // ArrayKind is the category for a JSON Schema that declares an // "array" type. ArrayKind // ReferenceKind is the category for a JSON Schema that is a reference // to another JSON Schema. During code generation, these references // are resolved using the API.schemas map. // See https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.28 // for more details on the format. ReferenceKind )
type MediaUpload ¶
type Method ¶
type Method struct { Name string ID string Path string HTTPMethod string Description string Parameters ParameterList ParameterOrder []string Request *Schema Response *Schema Scopes []string MediaUpload *MediaUpload SupportsMediaDownload bool APIVersion string JSONMap map[string]interface{} `json:"-"` }
A Method holds information about a resource method.
func (*Method) UnmarshalJSON ¶
type MethodList ¶
type MethodList []*Method
func (*MethodList) UnmarshalJSON ¶
func (ml *MethodList) UnmarshalJSON(data []byte) error
type ParameterList ¶
type ParameterList []*Parameter
func (*ParameterList) UnmarshalJSON ¶
func (pl *ParameterList) UnmarshalJSON(data []byte) error
type PropertyList ¶
type PropertyList []*Property
func (*PropertyList) UnmarshalJSON ¶
func (pl *PropertyList) UnmarshalJSON(data []byte) error
type Resource ¶
type Resource struct { Name string FullName string // {parent.FullName}.{Name} Methods MethodList Resources ResourceList }
A Resource holds information about a Google API Resource.
type ResourceList ¶
type ResourceList []*Resource
func (*ResourceList) UnmarshalJSON ¶
func (rl *ResourceList) UnmarshalJSON(data []byte) error
type Schema ¶
type Schema struct { ID string // union types not supported Type string // union types not supported Format string Description string Properties PropertyList ItemSchema *Schema `json:"items"` // array of schemas not supported AdditionalProperties *Schema // boolean not supported Ref string `json:"$ref"` Default string Pattern string Enums []string `json:"enum"` // Google extensions to JSON Schema EnumDescriptions []string Variant *Variant RefSchema *Schema `json:"-"` // Schema referred to by $ref Name string `json:"-"` // Schema name, if top level Kind Kind `json:"-"` }
A Schema holds a JSON Schema as defined by https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1. We only support the subset of JSON Schema needed for Google API generation.
func (*Schema) ElementSchema ¶
ElementSchema returns the schema for the element type of s. For maps, this is the schema of the map values. For arrays, it is the schema of the array item type.
ElementSchema panics if called on a schema that is not of kind map or array.
func (*Schema) IsIntAsString ¶
IsIntAsString reports whether the schema represents an integer value formatted as a string.
type Variant ¶
type Variant struct { Discriminant string Map []*VariantMapItem }