oapi_handlers

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 9 Imported by: 0

README

OpenAPI handlers

Go Reference

Hureg docs →

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOpenAPISpecMarshaller added in v1.0.0

func GetOpenAPISpecMarshaller(
	openApi *huma.OpenAPI,
	version OpenAPIVersion,
	format OpenAPIFormat,
) (marshaller func() ([]byte, error), contentType string, err error)

GetOpenAPISpecMarshaller returns a marshaller function that will return OpenAPI spec in the requested format and version.

Types

type OpenAPIFormat

type OpenAPIFormat string
const (
	OpenAPIFormatJSON OpenAPIFormat = "json"
	OpenAPIFormatYAML OpenAPIFormat = "yaml"
)

type OpenAPIVersion

type OpenAPIVersion string
const (
	OpenAPIVersion3dot0 OpenAPIVersion = "3.0"
	OpenAPIVersion3dot1 OpenAPIVersion = "3.1"
)

type SchemaRequest added in v1.0.0

type SchemaRequest struct {
	SchemaPath string `path:"schemaPath"`
}

type StreamResponseHandler added in v1.0.0

type StreamResponseHandler[I any] func(ctx context.Context, req I) (*huma.StreamResponse, error)

func GetDocsHandler added in v1.0.0

func GetDocsHandler(openAPI *huma.OpenAPI, openAPIYamlPath string) StreamResponseHandler[*struct{}]

GetDocsHandler returns a handler that will return HTML page that renders OpenAPI spec from the specified `openAPIYamlPath` URL. The handler format is suitable for passing it to huma or hureg registration functions.

func GetOpenAPISpecHandler added in v1.0.0

func GetOpenAPISpecHandler(
	openApi *huma.OpenAPI,
	version OpenAPIVersion,
	format OpenAPIFormat,
) (StreamResponseHandler[*struct{}], error)

GetOpenAPISpecHandler returns a handler that will return OpenAPI spec in the requested format and version. The handler format is suitable for passing it to huma or hureg registration functions

func GetSchemaHandler added in v1.0.0

func GetSchemaHandler(openAPI *huma.OpenAPI, schemasPath string) StreamResponseHandler[*SchemaRequest]

GetSchemaHandler returns a handler that will return a schema from the OpenAPI spec. The handler format is suitable for passing it to huma or hureg registration functions. `schemasPath` is a prefix to that will be added to all schema refs in the returned schema.

Jump to

Keyboard shortcuts

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