Documentation ¶
Index ¶
- Constants
- Variables
- func GetOpenAPIContent(urlBase string) *openapi3.Swagger
- func IsParameterReservedName(name string) bool
- func PathCollection(name string) string
- func PathCollectionItems(name string) string
- func PathFunction(name string) string
- func PathFunctionItems(name string) string
- func PathItem(name string, fid string) string
- func PathStripFormat(path string) string
- func RequestedFormat(r *http.Request) string
- func URLQuery(url *url.URL) string
- type Bbox
- type CollectionInfo
- type CollectionsInfo
- type Conformance
- type Extent
- type FeatureCollectionRaw
- type FunctionInfo
- type FunctionSummary
- type FunctionsInfo
- type Link
- type NameValMap
- type Parameter
- type Property
- type RequestParam
- type RootInfo
Constants ¶
const ( RootPageName = "index" TagCollections = "collections" TagItems = "items" TagConformance = "conformance" TagAPI = "api" TagFunctions = "functions" ParamCrs = "crs" ParamLimit = "limit" ParamOffset = "offset" ParamBbox = "bbox" ParamBboxCrs = "bbox-crs" ParamFilter = "filter" ParamFilterCrs = "filter-crs" ParamGroupBy = "groupby" ParamOrderBy = "orderby" ParamPrecision = "precision" ParamProperties = "properties" ParamSortBy = "sortby" ParamTransform = "transform" OrderByDirSep = ":" OrderByDirD = "d" OrderByDirA = "a" RelSelf = "self" RelAlt = "alternate" RelServiceDesc = "service-desc" RelServiceDoc = "service-doc" RelConformance = "conformance" RelData = "data" RelFunctions = "functions" RelItems = "items" TitleFeatuuresGeoJSON = "Features as GeoJSON" TitleDataJSON = "Data as JSON" TitleMetadata = "Metadata" TitleDocument = "This document" TitleAsJSON = " as JSON" TitleAsHTML = " as HTML" GeoJSONFeatureCollection = "FeatureCollection" )
const ( ErrMsgEncoding = "Error encoding response" ErrMsgLoadCollections = "Unable to access Collections" ErrMsgCollectionNotFound = "Collection not found: %v" ErrMsgCollectionAccess = "Unable to access Collection: %v" ErrMsgFeatureNotFound = "Feature not found: %v" ErrMsgLoadFunctions = "Unable to access Functions" ErrMsgFunctionNotFound = "Function not found: %v" ErrMsgFunctionAccess = "Unable to access Function: %v" ErrMsgInvalidParameterValue = "Invalid value for parameter %v: %v" ErrMsgInvalidQuery = "Invalid query parameters" ErrMsgDataReadError = "Unable to read data from: %v" ErrMsgDataWriteError = "Unable to write data to: %v" ErrMsgNoDataRead = "No data read from: %v" ErrMsgRequestTimeout = "Maximum time exceeded. Request cancelled." )
const ( ErrCodeCollectionNotFound = "CollectionNotFound" ErrCodeFeatureNotFound = "FeatureNotFound" )
const ( // ContentTypeJSON ContentTypeJSON = "application/json" // ContentTypeGeoJSON ContentTypeGeoJSON = "application/geo+json" // ContentTypeHTML ContentTypeHTML = "text/html" // ContentTypeText ContentTypeText = "text/plain" // ContentTypeSVG ContentTypeSVG = "image/svg+xml" // ContentTypeHTML ContentTypeOpenAPI = "application/vnd.oai.openapi+json;version=3.0" // FormatJSON code and extension for JSON FormatJSON = "json" // FormatHTML code and extension for HTML FormatHTML = "html" // FormatText code and extension for Text FormatText = "text" // FormatText code and extension for Text FormatSVG = "svg" )
Variables ¶
var BboxSchema openapi3.Schema = openapi3.Schema{ Type: "object", Required: []string{"bbox"}, Properties: map[string]*openapi3.SchemaRef{ "crs": { Value: openapi3.NewStringSchema(), }, "bbox": { Value: &openapi3.Schema{ Type: "array", MinItems: 4, MaxItems: openapi3.Uint64Ptr(4), Items: openapi3.NewSchemaRef("", openapi3.NewFloat64Schema().WithMin(-180).WithMax(180)), }, }, }, }
var CollectionInfoSchema openapi3.Schema = openapi3.Schema{ Type: "object", Required: []string{"id", "links"}, Properties: map[string]*openapi3.SchemaRef{ "id": {Value: &openapi3.Schema{Type: "string"}}, "title": {Value: &openapi3.Schema{Type: "string"}}, "description": {Value: &openapi3.Schema{Type: "string"}}, "extent": {Value: &ExtentSchema}, "crs": {Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{ Value: &openapi3.Schema{Type: "string"}, }, }, }, "geometrytype": {Value: &openapi3.Schema{Type: "string"}}, "properties": {Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{Value: &PropertySchema}, }, }, "links": {Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{Value: &LinkSchema}, }, }, }, }
var CollectionsInfoSchema openapi3.Schema = openapi3.Schema{ Type: "object", Required: []string{"links", "collections"}, Properties: map[string]*openapi3.SchemaRef{ "links": { Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{ Value: &LinkSchema, }, }, }, "collections": { Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{ Value: &CollectionInfoSchema, }, }, }, }, }
var ConformanceSchema openapi3.Schema = openapi3.Schema{ Type: "object", Required: []string{"conformsTo"}, Properties: map[string]*openapi3.SchemaRef{ "conformsTo": { Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{ Value: &openapi3.Schema{Type: "string"}, }, }, }, }, }
var ExtentSchema openapi3.Schema = openapi3.Schema{ Type: "object", Required: []string{"extent"}, Properties: map[string]*openapi3.SchemaRef{ "spatial": {Value: &BboxSchema}, }, }
var FunctionInfoSchema openapi3.Schema = openapi3.Schema{ Type: "object", Required: []string{"id", "links"}, Properties: map[string]*openapi3.SchemaRef{ "id": {Value: &openapi3.Schema{Type: "string"}}, "description": {Value: &openapi3.Schema{Type: "string"}}, "parameters": {Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{Value: &ParameterSchema}, }, }, "properties": {Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{Value: &PropertySchema}, }, }, "links": {Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{Value: &LinkSchema}, }, }, }, }
var FunctionSummarySchema openapi3.Schema = openapi3.Schema{ Type: "object", Required: []string{"id", "links"}, Properties: map[string]*openapi3.SchemaRef{ "id": {Value: &openapi3.Schema{Type: "string"}}, "description": {Value: &openapi3.Schema{Type: "string"}}, "links": {Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{Value: &LinkSchema}, }, }, }, }
var FunctionsInfoSchema openapi3.Schema = openapi3.Schema{ Type: "object", Required: []string{"links", "functions"}, Properties: map[string]*openapi3.SchemaRef{ "links": { Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{Value: &LinkSchema}, }, }, "functions": { Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{Value: &FunctionSummarySchema}, }, }, }, }
var LinkSchema openapi3.Schema = openapi3.Schema{ Description: "Describes links to other resources", Type: "object", Required: []string{"href"}, Properties: map[string]*openapi3.SchemaRef{ "href": {Value: &openapi3.Schema{Type: "string", Description: "URL for the link"}}, "rel": {Value: &openapi3.Schema{Type: "string"}}, "type": {Value: &openapi3.Schema{Type: "string"}}, "hreflang": {Value: &openapi3.Schema{Type: "string"}}, "title": {Value: &openapi3.Schema{Type: "string"}}, }, }
var ParamReservedNames = []string{ ParamCrs, ParamLimit, ParamOffset, ParamBbox, ParamBboxCrs, ParamFilter, ParamGroupBy, ParamOrderBy, ParamPrecision, ParamProperties, ParamSortBy, ParamTransform, }
var ParamReservedNamesMap = makeSet(ParamReservedNames)
var ParameterSchema openapi3.Schema = openapi3.Schema{ Description: "A parameter of a function", Type: "object", Required: []string{"name", "type"}, Properties: map[string]*openapi3.SchemaRef{ "name": {Value: &openapi3.Schema{Type: "string"}}, "type": {Value: &openapi3.Schema{Type: "string"}}, "default": {Value: &openapi3.Schema{Type: "string"}}, }, }
var PropertySchema openapi3.Schema = openapi3.Schema{ Description: "A data property of a collection or function result", Type: "object", Required: []string{"name", "type"}, Properties: map[string]*openapi3.SchemaRef{ "name": {Value: &openapi3.Schema{Type: "string"}}, "type": {Value: &openapi3.Schema{Type: "string"}}, "description": {Value: &openapi3.Schema{Type: "string"}}, }, }
var RootInfoSchema openapi3.Schema = openapi3.Schema{ Type: "object", Required: []string{"links"}, Properties: map[string]*openapi3.SchemaRef{ "title": {Value: &openapi3.Schema{ Type: "string", Description: "Title of this feature service", }}, "description": {Value: &openapi3.Schema{ Type: "string", Description: "Description of this feature service", }}, "links": { Value: &openapi3.Schema{ Type: "array", Items: &openapi3.SchemaRef{Value: &LinkSchema}, }, }, }, }
Functions ¶
func GetOpenAPIContent ¶
GetOpenAPIContent returns a Swagger OpenAPI structure
func IsParameterReservedName ¶
func PathCollection ¶
func PathCollectionItems ¶
func PathFunction ¶
func PathFunctionItems ¶
func PathStripFormat ¶
PathStripFormat removes a format extension from a path
func RequestedFormat ¶
RequestedFormat gets the format for a request from extension or headers
Types ¶
type CollectionInfo ¶
type CollectionInfo struct { Name string `json:"id"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Extent *Extent `json:"extent,omitempty"` Crs []string `json:"crs,omitempty"` GeometryType *string `json:"geometrytype,omitempty"` // these are omitempty so they don't show in summary metadata Properties []*Property `json:"properties,omitempty"` Links []*Link `json:"links"` // used for HTML response only URLMetadataHTML string `json:"-"` URLMetadataJSON string `json:"-"` URLItemsHTML string `json:"-"` URLItemsJSON string `json:"-"` }
CollectionInfo for a collection
func NewCollectionInfo ¶
func NewCollectionInfo(tbl *data.Table) *CollectionInfo
type CollectionsInfo ¶
type CollectionsInfo struct { Links []*Link `json:"links"` Collections []*CollectionInfo `json:"collections"` }
CollectionsInfo for all collections
func NewCollectionsInfo ¶
func NewCollectionsInfo(tables []*data.Table) *CollectionsInfo
type Conformance ¶
type Conformance struct {
ConformsTo []string `json:"conformsTo"`
}
func GetConformance ¶
func GetConformance() *Conformance
type Extent ¶
type Extent struct {
Spatial *Bbox `json:"spatial"`
}
Extent OAPIF Extent structure (partial)
type FeatureCollectionRaw ¶
type FeatureCollectionRaw struct { Type string `json:"type"` Features []*json.RawMessage `json:"features"` NumberMatched uint `json:"numberMatched,omitempty"` NumberReturned uint `json:"numberReturned"` TimeStamp string `json:"timeStamp,omitempty"` Links []*Link `json:"links"` }
FeatureCollection info
func NewFeatureCollectionInfo ¶
func NewFeatureCollectionInfo(featureJSON []string) *FeatureCollectionRaw
type FunctionInfo ¶
type FunctionInfo struct { Name string `json:"id"` Description string `json:"description,omitempty"` // these properties are always present but may be empty arrays Parameters []*Parameter `json:"parameters"` Properties []*Property `json:"properties"` Links []*Link `json:"links"` //--- additional data used during processing Function *data.Function `json:"-"` }
FunctionInfo is the API metadata for a function
func NewFunctionInfo ¶
func NewFunctionInfo(fn *data.Function) *FunctionInfo
type FunctionSummary ¶
type FunctionSummary struct { Name string `json:"id"` Description string `json:"description,omitempty"` Links []*Link `json:"links"` //--- additional data used during processing Function *data.Function `json:"-"` // used for HTML response only URLMetadataHTML string `json:"-"` URLMetadataJSON string `json:"-"` URLItemsHTML string `json:"-"` URLItemsJSON string `json:"-"` }
FunctionSummary contains a restricted set of function metadata for use in list display and JSON This allows not including parameters and properties in list metadata, but ensuring those keys are always present in full metadata JSON. Note: Collections do not follow same pattern because their list JSON metadata is supposed to contain all properties, and they are always expected to have attribute properties
func NewFunctionSummary ¶
func NewFunctionSummary(fn *data.Function) *FunctionSummary
type FunctionsInfo ¶
type FunctionsInfo struct { Links []*Link `json:"links"` Functions []*FunctionSummary `json:"functions"` }
FunctionsInfo is the API metadata for all functions
func NewFunctionsInfo ¶
func NewFunctionsInfo(fns []*data.Function) *FunctionsInfo
type Link ¶
type Link struct { Href string `json:"href"` Rel string `json:"rel"` Type string `json:"type"` Title string `json:"title"` }
Link for links
type NameValMap ¶
type Parameter ¶
type Parameter struct { Name string `json:"name"` Type string `json:"type"` Description string `json:"description"` Default string `json:"default,omitempty"` }
func FunctionParameters ¶
type Property ¶
type Property struct { Name string `json:"name"` Type string `json:"type"` Description string `json:"description"` }
func FunctionProperties ¶
func TableProperties ¶
type RequestParam ¶
type RequestParam struct { Crs int Limit int Offset int Bbox *data.Extent BboxCrs int Properties []string Filter string FilterCrs int GroupBy []string SortBy []data.Sorting Precision int TransformFuns []data.TransformFunction Values NameValMap }
RequestParam holds the parameters for a request