openapitest

package
v0.32.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEmbeddedFileClient added in v0.28.0

func NewEmbeddedFileClient() openapi.Client

NewEmbeddedFileClient returns a test client that uses the embedded `testdata` openapi files.

func NewFileClient

func NewFileClient(path string) openapi.Client

NewFileClient returns a test client implementing the openapi.Client interface, which serves Open API V3 specifications files from the given path, as prepared in `api/openapi-spec/v3`.

Types

type FakeClient

type FakeClient struct {
	// Hard-coded paths to return from Paths() function.
	PathsMap map[string]openapi.GroupVersion
	// Hard-coded returned error.
	ForcedErr error
}

FakeClient implements openapi.Client interface, with hard-coded return values, including the possibility to force errors.

func NewFakeClient

func NewFakeClient() *FakeClient

NewFakeClient returns a fake openapi client with an empty PathsMap.

func (FakeClient) Paths

func (f FakeClient) Paths() (map[string]openapi.GroupVersion, error)

Paths returns stored PathsMap field, creating an empty one if it does not already exist. If ForcedErr is set, this function returns the error instead.

type FakeGroupVersion

type FakeGroupVersion struct {
	// Hard-coded GroupVersion specification
	GVSpec []byte
	// Hard-coded returned error.
	ForcedErr error
}

FakeGroupVersion implements openapi.GroupVersion with hard-coded return GroupVersion specification bytes. If ForcedErr is set, then "Schema()" function returns the error instead of the GVSpec.

func (FakeGroupVersion) Schema

func (f FakeGroupVersion) Schema(contentType string) ([]byte, error)

Schema returns the hard-coded byte slice, including creating an empty slice if it has not been set yet. If the ForcedErr is set, this function returns the error instead of the GVSpec field. If content type other than application/json is passed, and error is returned.

Jump to

Keyboard shortcuts

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