openapi

package
v0.0.0-...-112d741 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package openapi contains code to generate OpenAPI discovery spec (which initial version of it also known as Swagger 2.0). For more details: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

Index

Constants

View Source
const (
	OpenAPIVersion = "2.0"

	JSON_EXT = ".json"

	MIME_JSON = "application/json"
	// TODO(mehdy): change @68f4ded to a version tag when gnostic add version tags.
	MIME_PB    = "application/com.github.googleapis.gnostic.OpenAPIv2@68f4ded+protobuf"
	MIME_PB_GZ = "application/x-gzip"
)
View Source
const (
	DEFINITION_PREFIX = "#/definitions/"
)

Variables

This section is empty.

Functions

func BuildSwaggerSpec

func BuildSwaggerSpec(webServices []*restful.WebService, config *openapi.Config) (*spec.Swagger, error)

func CloneSpec

func CloneSpec(source *spec.Swagger) (*spec.Swagger, error)

Clone OpenAPI spec

func EqualSchema

func EqualSchema(s1, s2 *spec.Schema) bool

EqualSchema returns true if models have the same properties and references even if they have different documentation.

func FilterSpecByPaths

func FilterSpecByPaths(sp *spec.Swagger, keepPathPrefixes []string)

FilterSpecByPaths remove unnecessary paths and unused definitions.

func MergeSpecs

func MergeSpecs(dest, source *spec.Swagger) error

Copy paths and definitions from source to dest, rename definitions if needed. dest will be mutated, and source will not be changed.

Types

type OpenAPIService

type OpenAPIService struct {
	// contains filtered or unexported fields
}

func RegisterOpenAPIService

func RegisterOpenAPIService(openapiSpec *spec.Swagger, servePath string, mux *genericmux.PathRecorderMux) (*OpenAPIService, error)

RegisterOpenAPIService registers a handler to provides standard OpenAPI specification.

func (*OpenAPIService) AddUpdateHook

func (o *OpenAPIService) AddUpdateHook(hook func(*http.Request))

Adds an update hook to be called on each spec request. The hook is responsible to call UpdateSpec method.

func (*OpenAPIService) GetSpec

func (o *OpenAPIService) GetSpec() *spec.Swagger

func (*OpenAPIService) UpdateSpec

func (o *OpenAPIService) UpdateSpec(openapiSpec *spec.Swagger) (err error)

Jump to

Keyboard shortcuts

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