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
- func BuildSwaggerSpec(webServices []*restful.WebService, config *openapi.Config) (*spec.Swagger, error)
- func CloneSpec(source *spec.Swagger) (*spec.Swagger, error)
- func EqualSchema(s1, s2 *spec.Schema) bool
- func FilterSpecByPaths(sp *spec.Swagger, keepPathPrefixes []string)
- func MergeSpecs(dest, source *spec.Swagger) error
- type OpenAPIService
Constants ¶
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" )
const (
DEFINITION_PREFIX = "#/definitions/"
)
Variables ¶
This section is empty.
Functions ¶
func BuildSwaggerSpec ¶ added in v1.7.0
func EqualSchema ¶ added in v1.7.0
EqualSchema returns true if models have the same properties and references even if they have different documentation.
func FilterSpecByPaths ¶ added in v1.7.0
FilterSpecByPaths remove unnecessary paths and unused definitions.
func MergeSpecs ¶ added in v1.7.0
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)