router

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPackageName = "openapi"

DefaultPackageName used in the router's source code

Variables

This section is empty.

Functions

func Generate

func Generate(specFile io.Reader, router io.Writer, opts Options) (err error)

Generate writes a chi router source code into `router` reading the YAML definition of the Open API 3.0 spec from the `specFile`. It supports options `opts` (see `Options`).

All included into generation endpoints must have `operationId` and `x-handler-group` attributes. Depending on the `opts` generator will either produce an error or skip endpoints without these attributes.

Types

type Options

type Options struct {
	// PackageName of the generated router source code (`DefaultPackageName` by default)
	PackageName string

	// FailNoGroup if true the generator returns an error if an endpoint without
	// `x-handler-group` attribute was found. Otherwise, this endpoint will be skipped silently.
	FailNoGroup bool

	// FailNoOperationID if true the generator returns an error if an endpoint without
	// `operationId` attribute was found. Otherwise, this endpoint will be skipped silently.
	FailNoOperationID bool
}

Options represent all the possible options of the generator

Jump to

Keyboard shortcuts

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