openapi

package
v1.7.16 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: Apache-2.0 Imports: 21 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 added in v1.7.0

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

func CloneSpec added in v1.7.0

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

Clone OpenAPI spec

func EqualSchema added in v1.7.0

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 added in v1.7.0

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

FilterSpecByPaths remove unnecessary paths and unused definitions.

func MergeSpecs added in v1.7.0

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 added in v1.7.0

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 added in v1.7.0

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 added in v1.7.0

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

func (*OpenAPIService) UpdateSpec added in v1.7.0

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