Documentation
¶
Index ¶
- func UniquePerRequest() func(*bodyOpt)
- func WithSchemaName(name string) func(*bodyOpt)
- type PathParam
- type Request
- func (r *Request) Body(contentType string, data interface{}, opts ...func(*bodyOpt)) *Request
- func (r *Request) Components(gen *openapi3gen.Generator, requestName string) (components openapi3.Components, err error)
- func (r *Request) Description(desc string) *Request
- func (r *Request) Header(h *header.Header) *Request
- func (r *Request) PathParams(params ...PathParam) *Request
- func (r *Request) Required(required bool) *Request
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 Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func NewRequest() *Request
func (*Request) Components ¶
func (r *Request) Components(gen *openapi3gen.Generator, requestName string) (components openapi3.Components, err error)
func (*Request) Description ¶
Description will be added to new line each called.