Documentation
¶
Index ¶
- func AddItem(cs *CollectionSchema, item ItemSchema)
- func Validate(cs CollectionSchema) error
- func WriteFile(filename string, cs CollectionSchema) error
- type AuthAwsV4Schema
- type AuthBasicSchema
- type AuthBearerSchema
- type AuthDigestSchema
- type AuthSchema
- type CollectionSchema
- type EnvironmentSchema
- type EnvironmentVariablesSchema
- type GraphqlBodySchema
- type ItemSchema
- type KeyValueSchema
- type MultipartFormSchema
- type Oauth2Schema
- type RequestBodySchema
- type RequestParamsSchema
- type RequestSchema
- type ScriptSchema
- type UIDSchema
- type VarsReqResSchema
- type VarsSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddItem ¶
func AddItem(cs *CollectionSchema, item ItemSchema)
AddItem appends an item (ItemSchema) to the existing Items slice. This is how you add a new request to the Collection.
CollectionSchema is passed as a pointer so changes are preserved on the heap.
func Validate ¶
func Validate(cs CollectionSchema) error
Validate performs data integrity checking based on the schema definition provided by the Bruno project.
func WriteFile ¶
func WriteFile(filename string, cs CollectionSchema) error
ToFile is a simple helper function that marshals the CollectionSchema and writes it to a file.
Types ¶
type AuthAwsV4Schema ¶
type AuthAwsV4Schema struct { AccessKeyId *string `validate:"omitempty"` SecretAccessKey *string `validate:"omitempty"` SessionToken *string `validate:"omitempty"` Service *string `validate:"omitempty"` Region *string `validate:"omitempty"` ProfileName *string `validate:"omitempty"` }
AuthAwsV4Schema represents the schema for AWS V4 authentication
type AuthBasicSchema ¶
type AuthBasicSchema struct { Username *string `validate:"omitempty"` Password *string `validate:"omitempty"` }
AuthBasicSchema represents the schema for basic authentication
type AuthBearerSchema ¶
type AuthBearerSchema struct {
Token *string `validate:"omitempty"`
}
AuthBearerSchema represents the schema for bearer authentication
type AuthDigestSchema ¶
type AuthDigestSchema struct { Username *string `validate:"omitempty"` Password *string `validate:"omitempty"` }
AuthDigestSchema represents the schema for digest authentication
type AuthSchema ¶
type AuthSchema struct { Mode string `validate:"required,oneof=inherit none awsv4 basic bearer digest oauth2"` AwsV4 *AuthAwsV4Schema `validate:"omitempty"` Basic *AuthBasicSchema `validate:"omitempty"` Bearer *AuthBearerSchema `validate:"omitempty"` Digest *AuthDigestSchema `validate:"omitempty"` Oauth2 *Oauth2Schema `validate:"omitempty"` }
AuthSchema represents the schema for authentication
type CollectionSchema ¶
type CollectionSchema struct { Version string `validate:"required,oneof=1"` UID UIDSchema Name string `validate:"required,min=1"` Items []ItemSchema `validate:"dive"` ActiveEnvironmentUID *string `validate:"omitempty,len=21,alphanum"` Environments []EnvironmentSchema `validate:"dive"` Pathname *string `validate:"omitempty"` RunnerResult map[string]interface{} `validate:"omitempty"` CollectionVariables map[string]interface{} `validate:"omitempty"` BrunoConfig map[string]interface{} `validate:"omitempty"` }
CollectionSchema represents the schema for collection
func CreateCollection ¶
func CreateCollection(name string, desc string) CollectionSchema
CreateCollection returns a new Collection.
func Parse ¶
func Parse(b []byte) (CollectionSchema, error)
Parse is a simple helper function that unmarshals the input bytes into a CollectionSchema whille also validating for data integrity. The caller can ignore validation errors if desired as the CollectionSchema is returned regardless.
func ParseFile ¶
func ParseFile(filename string) (CollectionSchema, error)
ParseFile is a simple helper funtion that reads a file, unmarshals the results into a CollectionSchema and then performs basic data validation. The caller can ignore validation errors if desired as the CollectionSchema is returned regardless.
type EnvironmentSchema ¶
type EnvironmentSchema struct { UID UIDSchema Name string `validate:"required,min=1"` Variables []EnvironmentVariablesSchema `validate:"required,dive"` }
EnvironmentSchema represents the schema for environment
type EnvironmentVariablesSchema ¶
type EnvironmentVariablesSchema struct { UID UIDSchema Name *string `validate:"omitempty"` Value *string `validate:"omitempty"` Type string `validate:"required,oneof=text"` Enabled bool `validate:"required"` Secret *bool `validate:"omitempty"` }
EnvironmentVariablesSchema represents the schema for environment variables
type GraphqlBodySchema ¶
type GraphqlBodySchema struct { Query *string `validate:"omitempty"` Variables *string `validate:"omitempty"` }
GraphqlBodySchema represents the schema for GraphQL body
type ItemSchema ¶
type ItemSchema struct { UID UIDSchema Type string `validate:"required,oneof=http graphql http-request graphql-request folder js"` Seq int `validate:"omitempty,min=1"` Name string `validate:"required,min=1"` Request *RequestSchema `validate:"required_if=Type http-request Type graphql-request'"` FileContent *string `validate:"omitempty"` Items []ItemSchema `validate:"omitempty,dive"` Filename *string `validate:"omitempty"` Pathname *string `validate:"omitempty"` }
ItemSchema represents the schema for item (aka a Request)
type KeyValueSchema ¶
type KeyValueSchema struct { UID UIDSchema Name *string `validate:"omitempty"` Value *string `validate:"omitempty"` Description *string `validate:"omitempty"` Enabled *bool `validate:"omitempty"` }
KeyValueSchema represents the schema for key-value pairs
type MultipartFormSchema ¶
type MultipartFormSchema struct { UID UIDSchema Type string `validate:"required,oneof=file text"` Name *string `validate:"omitempty"` Value *string `validate:"omitempty"` Description *string `validate:"omitempty"` Enabled *bool `validate:"omitempty"` }
MultipartFormSchema represents the schema for multipart form
type Oauth2Schema ¶
type Oauth2Schema struct { GrantType string `validate:"required,oneof=client_credentials password authorization_code"` Username *string `validate:"omitempty"` Password *string `validate:"omitempty"` CallbackUrl *string `validate:"omitempty"` AuthorizationUrl *string `validate:"omitempty"` AccessTokenUrl *string `validate:"omitempty"` ClientId *string `validate:"omitempty"` ClientSecret *string `validate:"omitempty"` Scope *string `validate:"omitempty"` State *string `validate:"omitempty"` Pkce *bool `validate:"omitempty"` }
Oauth2Schema represents the schema for OAuth2
type RequestBodySchema ¶
type RequestBodySchema struct { Mode string `validate:"required,oneof=none json text xml formUrlEncoded multipartForm graphql sparql"` JSON *string `validate:"omitempty"` Text *string `validate:"omitempty"` XML *string `validate:"omitempty"` Sparql *string `validate:"omitempty"` FormUrlEncoded []KeyValueSchema `validate:"omitempty,dive"` MultipartForm []MultipartFormSchema `validate:"omitempty,dive"` Graphql *GraphqlBodySchema `validate:"omitempty"` }
RequestBodySchema represents the schema for request body
type RequestParamsSchema ¶
type RequestParamsSchema struct { UID UIDSchema Name *string `validate:"omitempty"` Value *string `validate:"omitempty"` Description *string `validate:"omitempty"` Type string `validate:"required,oneof=query path"` Enabled *bool `validate:"omitempty"` }
RequestParamsSchema represents the schema for request parameters
type RequestSchema ¶
type RequestSchema struct { URL string `validate:"required"` Method string `validate:"required,oneof=GET POST PUT DELETE PATCH HEAD OPTIONS"` Headers []KeyValueSchema `validate:"required,dive"` Params []RequestParamsSchema `validate:"dive"` // Bruno does not always output these Auth AuthSchema `validate:"required"` Body RequestBodySchema `validate:"required"` Script ScriptSchema `validate:"required"` Vars *VarsReqResSchema `validate:"omitempty"` Assertions []KeyValueSchema `validate:"omitempty,dive"` Tests *string `validate:"omitempty"` Docs *string `validate:"omitempty"` }
RequestSchema represents the schema for request
func CreateRequest ¶
func CreateRequest(url string, method string) *RequestSchema
CreateRequest returns a minimally populated RequestSchema. The return value will pass data validation because the minimum set of fields is filled in with default values.
type ScriptSchema ¶
ScriptSchema represents the schema for script
type VarsReqResSchema ¶
type VarsReqResSchema struct { Req []VarsSchema `validate:"omitempty,dive"` Res []VarsSchema `validate:"omitempty,dive"` }
VarsReqResSchema represents the schema for vars in request and response