wfs3

package
v0.0.1-0...-132fcf6 Latest Latest
Warning

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

Go to latest
Published: May 11, 2018 License: MIT Imports: 15 Imported by: 0

README

This package provides go structs conforming to api schemas defined by the wfs3 spec. This package provides go structs defining the schemas of these structs (via kin-openapi/openapi3) for easy use in validation & generating an openapi3 document. This package provides functions used by the handlers package to collect content in the form of read-to-be-marshalled go structs. Currently only marshalling to JSON is supported.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BBoxSchema openapi3.Schema = openapi3.Schema{
	Type:      "array",
	Items:     &openapi3.SchemaRef{Value: openapi3.NewFloat64Schema()},
	MinLength: int64(4),
	MaxLength: pint64(4),
}
View Source
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: &maxItems,
				Items:    openapi3.NewSchemaRef("", openapi3.NewFloat64Schema().WithMin(-180).WithMax(180)),
			},
		},
	},
}
View Source
var CollectionInfoSchema openapi3.Schema = openapi3.Schema{
	Type:     "object",
	Required: []string{"name", "links"},
	Properties: map[string]*openapi3.SchemaRef{
		"name": {
			Value: &openapi3.Schema{
				Type: "string",
			},
		},
		"title": {
			Value: &openapi3.Schema{
				Type: "string",
			},
		},
		"description": {
			Value: &openapi3.Schema{
				Type: "string",
			},
		},
		"links": {
			Value: &openapi3.Schema{
				Type: "array",
				Items: &openapi3.SchemaRef{
					Value: &LinkSchema,
				},
			},
		},
		"extent": {
			Value: &BboxSchema,
		},
		"crs": {
			Value: &openapi3.Schema{
				Type: "array",
				Items: &openapi3.SchemaRef{
					Value: &openapi3.Schema{
						Type: "string",
					},
				},
			},
		},
	},
}
View Source
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,
				},
			},
		},
	},
}
View Source
var ConformanceClassesSchema 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",
					},
				},
			},
		},
	},
}
View Source
var FeatureCollectionJSONSchema string = `` /* 16871-byte string literal not displayed */

Collected from: http://geojson.org/schema/FeatureCollection.json 2018-04-02

View Source
var FeatureJSONSchema string = `` /* 13542-byte string literal not displayed */

Collected from http://geojson.org/schema/Feature.json on 2018-03-02

View Source
var LinkSchema openapi3.Schema = openapi3.Schema{
	Type:     "object",
	Required: []string{"href"},
	Properties: map[string]*openapi3.SchemaRef{
		"href": {
			Value: &openapi3.Schema{
				Type: "string",
			},
		},
		"rel": {
			Value: &openapi3.Schema{
				Type: "string",
			},
		},
		"type": {
			Value: &openapi3.Schema{
				Type: "string",
			},
		},
		"hreflang": {
			Value: &openapi3.Schema{
				Type: "string",
			},
		},
		"title": {
			Value: &openapi3.Schema{
				Type: "string",
			},
		},
	},
}
View Source
var RootContentSchema openapi3.Schema = openapi3.Schema{
	Type:     "object",
	Required: []string{"links"},
	Properties: map[string]*openapi3.SchemaRef{
		"links": {
			Value: &openapi3.Schema{
				Type: "array",
				Items: &openapi3.SchemaRef{
					Value: &LinkSchema,
				},
			},
		},
	},
}

Functions

func GenerateOpenAPIDocument

func GenerateOpenAPIDocument()

func OpenAPI3Schema

func OpenAPI3Schema() *openapi3.Swagger

func OpenAPI3SchemaEncoded

func OpenAPI3SchemaEncoded(encoding string) (encodedContent []byte, contentId string)

func ValidateJSONResponse

func ValidateJSONResponse(request *http.Request, path string, status int, header http.Header, respBodyRC io.ReadCloser) error

Validate a json response provided by a Reader using kin-openapi/openapi3 against the openapi3

scaffolding set up in wfs3/openapi3.go

func ValidateJSONResponseAgainstJSONSchema

func ValidateJSONResponseAgainstJSONSchema(jsonResponse []byte, jsonSchema string) error

Validate a Reader providing the response body against a string json schema

Types

type Bbox

type Bbox struct {
	Crs  string    `json:"crs"`
	Bbox []float64 `json:"bbox"`
}

type CollectionInfo

type CollectionInfo struct {
	Name        string   `json:"name"`
	Title       string   `json:"title,omitempty"`
	Description string   `json:"description,omitempty"`
	Links       []*Link  `json:"links"`
	Extent      *Bbox    `json:"extent,omitempty"`
	Crs         []string `json:"crs,omitempty"`
}

--- @See https://raw.githubusercontent.com/opengeospatial/WFS_FES/master/core/openapi/schemas/collectionInfo.yaml

for collectionInfo schema

func CollectionMetaData

func CollectionMetaData(name string, p *data_provider.Provider, serveAddress string, checkOnly bool) (content *CollectionInfo, contentId string, err error)

func (*CollectionInfo) ContentType

func (ci *CollectionInfo) ContentType(contentType string)

func (*CollectionInfo) MarshalHTML

func (ci *CollectionInfo) MarshalHTML(c config.Config) ([]byte, error)

type CollectionsInfo

type CollectionsInfo struct {
	Links       []*Link           `json:"links"`
	Collections []*CollectionInfo `json:"collections"`
}

--- @See https://raw.githubusercontent.com/opengeospatial/WFS_FES/master/core/openapi/schemas/content.yaml

for collectionsInfo schema.

func CollectionsMetaData

func CollectionsMetaData(p *data_provider.Provider, serveAddress string, checkOnly bool) (content *CollectionsInfo, contentId string, err error)

func (*CollectionsInfo) ContentType

func (csi *CollectionsInfo) ContentType(contentType string)

func (*CollectionsInfo) MarshalHTML

func (csi *CollectionsInfo) MarshalHTML(c config.Config) ([]byte, error)

type ConformanceClasses

type ConformanceClasses struct {
	ConformsTo []string `json:"conformsTo"`
}

--- @See https://raw.githubusercontent.com/opengeospatial/WFS_FES/master/core/openapi/schemas/req-classes.yaml

for ConformanceClasses schema

func Conformance

func Conformance() (content *ConformanceClasses, contentId string)

--- Implements req/core/conformance-op

func (*ConformanceClasses) MarshalHTML

func (ccs *ConformanceClasses) MarshalHTML(c config.Config) ([]byte, error)

type Feature

type Feature struct {
	geojson.Feature
	Links []*Link `json:"links,omitempty"`
}

func FeatureData

func FeatureData(cname string, fid uint64, p *data_provider.Provider, checkOnly bool) (content *Feature, contentId string, err error)

func (*Feature) MarshalHTML

func (f *Feature) MarshalHTML(c config.Config) ([]byte, error)

type FeatureCollection

type FeatureCollection struct {
	geojson.FeatureCollection
	Links          []*Link `json:"links,omitempty"`
	NumberMatched  uint    `json:"numberMatched,omitempty"`
	NumberReturned uint    `json:"numberReturned,omitempty"`
}

func FeatureCollectionData

func FeatureCollectionData(cName string, bbox *geom.Extent, startIdx, stopIdx uint, properties map[string]string, p *data_provider.Provider, checkOnly bool) (content *FeatureCollection, featureTotal uint, contentId string, err error)

func (*FeatureCollection) MarshalHTML

func (fc *FeatureCollection) MarshalHTML(c config.Config) ([]byte, error)
type Link struct {
	Href     string `json:"href"`
	Rel      string `json:"rel"`
	Type     string `json:"type"`
	Hreflang string `json:"hreflang"`
	Title    string `json:"title"`
}

--- @See https://raw.githubusercontent.com/opengeospatial/WFS_FES/master/core/openapi/schemas/link.yaml

for link schema

func (*Link) ContentType

func (l *Link) ContentType(contentType string)

type RootContent

type RootContent struct {
	Links []*Link `json:"links"`
}

--- @See http://raw.githubusercontent.com/opengeospatial/WFS_FES/master/core/openapi/schemas/root.yaml

for rootContentSchema Definition

What the endpoint at "/" returns

func Root

func Root(checkOnly bool) (content *RootContent, contentId string)

checkOnly indicates that the caller doesn't care about the content, only the contentId contentId is a string that changes as the content changes, useful for ETag & caching.

func (*RootContent) MarshalHTML

func (rc *RootContent) MarshalHTML(c config.Config) ([]byte, error)

Jump to

Keyboard shortcuts

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