apispec

package
v0.0.0-...-8b8482c Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Package apispec provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.16.2 DO NOT EDIT.

Index

Constants

View Source
const (
	JWTScopes = "JWT.Scopes"
)

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func NewPostApiV1DependenciesEventRequest

func NewPostApiV1DependenciesEventRequest(server string, body PostApiV1DependenciesEventJSONRequestBody) (*http.Request, error)

NewPostApiV1DependenciesEventRequest calls the generic PostApiV1DependenciesEvent builder with application/json body

func NewPostApiV1DependenciesEventRequestWithBody

func NewPostApiV1DependenciesEventRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewPostApiV1DependenciesEventRequestWithBody generates requests for PostApiV1DependenciesEvent with any type of body

func NewPostApiV1PipelineEventRequest

func NewPostApiV1PipelineEventRequest(server string, body PostApiV1PipelineEventJSONRequestBody) (*http.Request, error)

NewPostApiV1PipelineEventRequest calls the generic PostApiV1PipelineEvent builder with application/json body

func NewPostApiV1PipelineEventRequestWithBody

func NewPostApiV1PipelineEventRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewPostApiV1PipelineEventRequestWithBody generates requests for PostApiV1PipelineEvent with any type of body

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router gin.IRouter, si ServerInterface)

RegisterHandlers creates http.Handler with routing matching OpenAPI spec.

func RegisterHandlersWithOptions

func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)

RegisterHandlersWithOptions creates http.Handler with additional options

Types

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) PostApiV1DependenciesEvent

func (c *Client) PostApiV1DependenciesEvent(ctx context.Context, body PostApiV1DependenciesEventJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) PostApiV1DependenciesEventWithBody

func (c *Client) PostApiV1DependenciesEventWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) PostApiV1PipelineEvent

func (c *Client) PostApiV1PipelineEvent(ctx context.Context, body PostApiV1PipelineEventJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) PostApiV1PipelineEventWithBody

func (c *Client) PostApiV1PipelineEventWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// PostApiV1DependenciesEventWithBody request with any body
	PostApiV1DependenciesEventWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	PostApiV1DependenciesEvent(ctx context.Context, body PostApiV1DependenciesEventJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// PostApiV1PipelineEventWithBody request with any body
	PostApiV1PipelineEventWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	PostApiV1PipelineEvent(ctx context.Context, body PostApiV1PipelineEventJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) PostApiV1DependenciesEventWithBodyWithResponse

func (c *ClientWithResponses) PostApiV1DependenciesEventWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV1DependenciesEventResponse, error)

PostApiV1DependenciesEventWithBodyWithResponse request with arbitrary body returning *PostApiV1DependenciesEventResponse

func (*ClientWithResponses) PostApiV1DependenciesEventWithResponse

func (c *ClientWithResponses) PostApiV1DependenciesEventWithResponse(ctx context.Context, body PostApiV1DependenciesEventJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV1DependenciesEventResponse, error)

func (*ClientWithResponses) PostApiV1PipelineEventWithBodyWithResponse

func (c *ClientWithResponses) PostApiV1PipelineEventWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV1PipelineEventResponse, error)

PostApiV1PipelineEventWithBodyWithResponse request with arbitrary body returning *PostApiV1PipelineEventResponse

func (*ClientWithResponses) PostApiV1PipelineEventWithResponse

func (c *ClientWithResponses) PostApiV1PipelineEventWithResponse(ctx context.Context, body PostApiV1PipelineEventJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV1PipelineEventResponse, error)

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// PostApiV1DependenciesEventWithBodyWithResponse request with any body
	PostApiV1DependenciesEventWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV1DependenciesEventResponse, error)

	PostApiV1DependenciesEventWithResponse(ctx context.Context, body PostApiV1DependenciesEventJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV1DependenciesEventResponse, error)

	// PostApiV1PipelineEventWithBodyWithResponse request with any body
	PostApiV1PipelineEventWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostApiV1PipelineEventResponse, error)

	PostApiV1PipelineEventWithResponse(ctx context.Context, body PostApiV1PipelineEventJSONRequestBody, reqEditors ...RequestEditorFn) (*PostApiV1PipelineEventResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type DependencyEvent

type DependencyEvent struct {
	GithubContext GitHubDependencyEventContext `json:"github_context"`

	// Verdict The verdict of the event
	Verdict models.Verdict `json:"verdict"`
}

DependencyEvent defines model for DependencyEvent.

type Error

type Error struct {
	Identifier *string `json:"identifier,omitempty"`
	Message    string  `json:"message"`
}

Error defines model for Error.

type GinServerOptions

type GinServerOptions struct {
	BaseURL      string
	Middlewares  []MiddlewareFunc
	ErrorHandler func(*gin.Context, error, int)
}

GinServerOptions provides options for the Gin server.

type GitHubDependencyEventContext

type GitHubDependencyEventContext = GitHubEventContext

GitHubDependencyEventContext defines model for GitHubDependencyEventContext.

type GitHubEventContext

type GitHubEventContext struct {
	Action            string                  `json:"action"`
	ActionPath        *string                 `json:"action_path,omitempty"`
	ActionRepository  *string                 `json:"action_repository,omitempty"`
	Actor             string                  `json:"actor"`
	ActorId           int64string.Int64String `json:"actor_id"`
	EventName         string                  `json:"event_name"`
	Job               string                  `json:"job"`
	Ref               string                  `json:"ref"`
	RefName           string                  `json:"ref_name"`
	RefProtected      bool                    `json:"ref_protected"`
	RefType           string                  `json:"ref_type"`
	Repository        string                  `json:"repository"`
	RepositoryId      int64string.Int64String `json:"repository_id"`
	RepositoryOwner   string                  `json:"repository_owner"`
	RepositoryOwnerId int64string.Int64String `json:"repository_owner_id"`
	RunAttempt        int64string.Int64String `json:"run_attempt"`
	RunId             int64string.Int64String `json:"run_id"`
	RunNumber         int64string.Int64String `json:"run_number"`
	RunnerArch        string                  `json:"runner_arch"`
	RunnerDebug       *bool                   `json:"runner_debug,omitempty"`
	RunnerOs          string                  `json:"runner_os"`
	ServerUrl         string                  `json:"server_url"`
	Sha               string                  `json:"sha"`
	TriggeringActor   string                  `json:"triggering_actor"`
	Workflow          string                  `json:"workflow"`
	WorkflowRef       string                  `json:"workflow_ref"`
	Workspace         string                  `json:"workspace"`
}

GitHubEventContext defines model for GitHubEventContext.

type GitHubPipelineEventContext

type GitHubPipelineEventContext = GitHubEventContext

GitHubPipelineEventContext defines model for GitHubPipelineEventContext.

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type MiddlewareFunc

type MiddlewareFunc func(c *gin.Context)

type PipelineEvent

type PipelineEvent struct {
	Data          interface{}                `json:"data"`
	GithubContext GitHubPipelineEventContext `json:"github_context"`
	Type          string                     `json:"type"`
}

PipelineEvent defines model for PipelineEvent.

type PostApiV1DependenciesEventJSONRequestBody

type PostApiV1DependenciesEventJSONRequestBody = DependencyEvent

PostApiV1DependenciesEventJSONRequestBody defines body for PostApiV1DependenciesEvent for application/json ContentType.

type PostApiV1DependenciesEventResponse

type PostApiV1DependenciesEventResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON401      *Error
	JSON500      *Error
}

func ParsePostApiV1DependenciesEventResponse

func ParsePostApiV1DependenciesEventResponse(rsp *http.Response) (*PostApiV1DependenciesEventResponse, error)

ParsePostApiV1DependenciesEventResponse parses an HTTP response from a PostApiV1DependenciesEventWithResponse call

func (PostApiV1DependenciesEventResponse) Status

Status returns HTTPResponse.Status

func (PostApiV1DependenciesEventResponse) StatusCode

func (r PostApiV1DependenciesEventResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type PostApiV1PipelineEventJSONRequestBody

type PostApiV1PipelineEventJSONRequestBody = PipelineEvent

PostApiV1PipelineEventJSONRequestBody defines body for PostApiV1PipelineEvent for application/json ContentType.

type PostApiV1PipelineEventResponse

type PostApiV1PipelineEventResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON401      *Error
	JSON500      *Error
}

func ParsePostApiV1PipelineEventResponse

func ParsePostApiV1PipelineEventResponse(rsp *http.Response) (*PostApiV1PipelineEventResponse, error)

ParsePostApiV1PipelineEventResponse parses an HTTP response from a PostApiV1PipelineEventWithResponse call

func (PostApiV1PipelineEventResponse) Status

Status returns HTTPResponse.Status

func (PostApiV1PipelineEventResponse) StatusCode

func (r PostApiV1PipelineEventResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type ServerInterface

type ServerInterface interface {
	// Create a new dependency event
	// (POST /api/v1/dependencies/event)
	PostApiV1DependenciesEvent(c *gin.Context)
	// Create a new pipeline event
	// (POST /api/v1/pipeline/event)
	PostApiV1PipelineEvent(c *gin.Context)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandler       func(*gin.Context, error, int)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) PostApiV1DependenciesEvent

func (siw *ServerInterfaceWrapper) PostApiV1DependenciesEvent(c *gin.Context)

PostApiV1DependenciesEvent operation middleware

func (*ServerInterfaceWrapper) PostApiV1PipelineEvent

func (siw *ServerInterfaceWrapper) PostApiV1PipelineEvent(c *gin.Context)

PostApiV1PipelineEvent operation middleware

Jump to

Keyboard shortcuts

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