restfulspec

package module
v0.0.0-...-c36cb6c Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2017 License: MIT Imports: 4 Imported by: 0

README

go-restful-openapi

Build Status GoDoc

openapi extension to the go-restful package, targeting version 2.0

work in progress

dependencies

© 2017, ernestmicklei.com. MIT License. Contributions welcome.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterOpenAPIService

func RegisterOpenAPIService(config Config, wsContainer *restful.Container)

RegisterOpenAPIService adds the WebService that provides the API documentation of all services conform the OpenAPI documentation specifcation.

Types

type Config

type Config struct {
	// WebServicesURL is the url where the services are available, e.g. http://localhost:8080
	// if left empty then the basePath of Swagger is taken from the actual request
	WebServicesURL string
	// APIPath is the path where the JSON api is avaiable , e.g. /apidocs
	APIPath string
	// SwaggerPath [optional] where the swagger UI will be served, e.g. /swagger
	SwaggerPath string
	// SwaggerFilePath [optional] is the location of folder containing Swagger HTML5 application index.html
	SwaggerFilePath string
	// api listing is constructed from this list of restful WebServices.
	WebServices []*restful.WebService
	// will serve all static content (scripts,pages,images)
	StaticHandler http.Handler
	// [optional] on default CORS (Cross-Origin-Resource-Sharing) is enabled.
	DisableCORS bool
	// Top-level API version. Is reflected in the resource listing.
	APIVersion string
	// OpenAPI global info struct
	Info spec.Info
	// [optional] If set, model builder should call this handler to get addition typename-to-swagger-format-field conversion.
	SchemaFormatHandler MapSchemaFormatFunc
	// [optional] If set, model builder should call this handler to retrieve the name for a given type.
	ModelTypeNameHandler MapModelTypeNameFunc
}

Config holds service api metadata.

type MapModelTypeNameFunc

type MapModelTypeNameFunc func(t reflect.Type) (string, bool)

MapModelTypeNameFunc can be used to return the desired typeName for a given type. It will return false if the default name should be used.

type MapSchemaFormatFunc

type MapSchemaFormatFunc func(typeName string) string

MapSchemaFormatFunc can be used to modify typeName at definition time.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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