request

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniquePerRequest

func UniquePerRequest() func(*bodyOpt)

UniquePerRequest if set to true, then we will add hash request method:path to the schema name prefix. This to make sure if we add the same struct to multiple request, then each request will have different schema. This useful when you have general struct as parent wrapper. For example, you have this struct:

type ReqWrapper struct {
	 Data interface{} `json:"data"`
}

and `data` field will be assigned to different struct on each request. I.e: req1 has body: {"data": {"username": "user-name"}} I.e: req2 has body: {"data": {"teamName": "team-name"}} req1 and req2 can share the same 'wrapper' struct such as ReqWrapper, and calling this UniquePerRequest will ensure that those two payload is generated with different schema name.

func WithSchemaName

func WithSchemaName(name string) func(*bodyOpt)

WithSchemaName to override generated schema name from struct name to this name. For example, if you don't specify this it will use package.StructName as the schema name, but if you define this, then we will use this as the schema name.

Types

type PathParam

type PathParam struct {
	Name        string
	Value       interface{}
	Description string
}

type Request

type Request struct {
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest() *Request

func (*Request) Body

func (r *Request) Body(contentType string, data interface{}, opts ...func(*bodyOpt)) *Request

func (*Request) Components

func (r *Request) Components(gen *openapi3gen.Generator, requestName string) (components openapi3.Components, err error)

func (*Request) Description

func (r *Request) Description(desc string) *Request

Description will be added to new line each called.

func (*Request) Header

func (r *Request) Header(h *header.Header) *Request

func (*Request) PathParams

func (r *Request) PathParams(params ...PathParam) *Request

func (*Request) Required

func (r *Request) Required(required bool) *Request

Required must be called once to mark whether this Request is required or not.

Jump to

Keyboard shortcuts

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