restapi

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package restapi Swagger Petstore This is a simplifed version of the sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `token` to test the authorization filters.

Schemes:
  http
Host: petstore.org
BasePath: /api
Version: 1.0.0

Consumes:
- application/json

Produces:
- application/json

swagger:meta

Code generated by mockery v1.0.0

Code generated by mockery v1.0.0

Index

Constants

View Source
const AuthKey contextKey = "Auth"

Variables

View Source
var (
	CategoryQueryParse = query.MustNewBuilder(&query.Config{Model: models.Category{}}).ParseRequest
	OrderQueryParse    = query.MustNewBuilder(&query.Config{Model: models.Order{}}).ParseRequest
	PetQueryParse      = query.MustNewBuilder(&query.Config{Model: models.Pet{}}).ParseRequest
	TagQueryParse      = query.MustNewBuilder(&query.Config{Model: models.Tag{}}).ParseRequest
)

Query parse functions for all the models Those can be used to extract database query from the http path's query string

View Source
var (
	// SwaggerJSON embedded version of the swagger document used at generation time
	SwaggerJSON json.RawMessage
	// FlatSwaggerJSON embedded flattened version of the swagger document used at generation time
	FlatSwaggerJSON json.RawMessage
)

Functions

func Handler

func Handler(c Config) (http.Handler, error)

Handler returns an http.Handler given the handler configuration It mounts all the business logic implementers in the right routing.

Types

type Config

type Config struct {
	PetAPI
	StoreAPI
	Logger func(string, ...interface{})
	// InnerMiddleware is for the handler executors. These do not apply to the swagger.json document.
	// The middleware executes after routing but before authentication, binding and validation
	InnerMiddleware func(http.Handler) http.Handler

	// Authorizer is used to authorize a request after the Auth function was called using the "Auth*" functions
	// and the principal was stored in the context in the "AuthKey" context value.
	Authorizer func(*http.Request) error

	// AuthToken Applies when the "Cookie" header is set
	AuthToken func(token string) (interface{}, error)
}

Config is configuration for Handler

type MockPetAPI

type MockPetAPI struct {
	mock.Mock
}

MockPetAPI is an autogenerated mock type for the PetAPI type

func (*MockPetAPI) PetCreate

func (_m *MockPetAPI) PetCreate(ctx context.Context, params pet.PetCreateParams) middleware.Responder

PetCreate provides a mock function with given fields: ctx, params

func (*MockPetAPI) PetDelete

func (_m *MockPetAPI) PetDelete(ctx context.Context, params pet.PetDeleteParams) middleware.Responder

PetDelete provides a mock function with given fields: ctx, params

func (*MockPetAPI) PetGet

func (_m *MockPetAPI) PetGet(ctx context.Context, params pet.PetGetParams) middleware.Responder

PetGet provides a mock function with given fields: ctx, params

func (*MockPetAPI) PetList

func (_m *MockPetAPI) PetList(ctx context.Context, params pet.PetListParams) middleware.Responder

PetList provides a mock function with given fields: ctx, params

func (*MockPetAPI) PetUpdate

func (_m *MockPetAPI) PetUpdate(ctx context.Context, params pet.PetUpdateParams) middleware.Responder

PetUpdate provides a mock function with given fields: ctx, params

type MockStoreAPI

type MockStoreAPI struct {
	mock.Mock
}

MockStoreAPI is an autogenerated mock type for the StoreAPI type

func (*MockStoreAPI) InventoryGet

InventoryGet provides a mock function with given fields: ctx, params

func (*MockStoreAPI) OrderCreate

OrderCreate provides a mock function with given fields: ctx, params

func (*MockStoreAPI) OrderDelete

OrderDelete provides a mock function with given fields: ctx, params

func (*MockStoreAPI) OrderGet

OrderGet provides a mock function with given fields: ctx, params

type PetAPI

type PetAPI interface {
	PetCreate(ctx context.Context, params pet.PetCreateParams) middleware.Responder
	PetDelete(ctx context.Context, params pet.PetDeleteParams) middleware.Responder
	PetGet(ctx context.Context, params pet.PetGetParams) middleware.Responder
	PetList(ctx context.Context, params pet.PetListParams) middleware.Responder
	PetUpdate(ctx context.Context, params pet.PetUpdateParams) middleware.Responder
}

PetAPI

type StoreAPI

type StoreAPI interface {
	InventoryGet(ctx context.Context, params store.InventoryGetParams) middleware.Responder
	OrderCreate(ctx context.Context, params store.OrderCreateParams) middleware.Responder
	// OrderDelete is For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors
	OrderDelete(ctx context.Context, params store.OrderDeleteParams) middleware.Responder
	// OrderGet is For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions
	OrderGet(ctx context.Context, params store.OrderGetParams) middleware.Responder
}

StoreAPI

Directories

Path Synopsis
pet

Jump to

Keyboard shortcuts

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