Documentation ¶
Index ¶
- func BaseParamToStringCode() string
- func BaseStringToTypeCode() string
- func Capitalize(input string) string
- func CodeToTypeMap(op *spec.Operation) map[int]string
- func DefaultAsString(param spec.Parameter) string
- func ImportStatements(imports []string) string
- func InitCustomFormats()
- func Interface(op *spec.Operation) string
- func InterfaceComment(method, path string, op *spec.Operation) string
- func NoSuccessType(op *spec.Operation) bool
- func OutputType(op *spec.Operation, statusCode int) (string, bool)
- func ParamToStringCode(param spec.Parameter) string
- func ParamToType(param spec.Parameter, withPointer bool) (string, error)
- func ParamToValidationCode(param spec.Parameter) ([]string, error)
- func PathItemOperations(item spec.PathItem) map[string]*spec.Operation
- func SingleSchemaedBodyParameter(op *spec.Operation) (bool, string)
- func SortedOperationsKeys(m map[string]*spec.Operation) []string
- func SortedPathItemKeys(m map[string]spec.PathItem) []string
- func SortedStatusCodeKeys(m map[int]spec.Response) []int
- func StringToTypeCode(strField string, param spec.Parameter) (string, error)
- func StructParamName(param spec.Parameter) string
- func TypeFromSchema(schema *spec.Schema, includeModels bool) (string, error)
- func WagPatchDataTypes(paths map[string]spec.PathItem) (map[string]struct{}, error)
- type Generator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseParamToStringCode ¶
func BaseParamToStringCode() string
BaseParamToStringCode returns the code for a function that joins a string array by a known format (csv, ssv, tsv, pipes).
func BaseStringToTypeCode ¶
func BaseStringToTypeCode() string
BaseStringToTypeCode is the helper code from base string to type
func CodeToTypeMap ¶
CodeToTypeMap returns a map from return status code to its corresponding type
func DefaultAsString ¶
DefaultAsString returns the default value as a string. We convert it into a string so it's easier to insert into the generated code and it doesn't make this logic really any different.
func ImportStatements ¶
ImportStatements takes a list of import strings and converts them to a formatted imports
func InitCustomFormats ¶
func InitCustomFormats()
InitCustomFormats adds wag's custom formats to the global go-openapi/strfmt Default registry.
func InterfaceComment ¶
InterfaceComment returns the comment for the interface for the operation
func NoSuccessType ¶
NoSuccessType returns true if the operation has no-success response type. This includes either no 200-399 response code or a 200-399 response code without a schema.
func OutputType ¶
OutputType returns the output type for a given status code of an operation and whether it is a pointer in the interface.
func ParamToStringCode ¶
ParamToStringCode returns a function that converts a Parameter into the code to convert it into a string (for serialization). For example, a integer named 'Size' becomes `strconv.FormatInt(i.Size, 10)`
func ParamToType ¶
ParamToType converts a parameter into its Go type. If withPointer is true it will make the variable a pointer if it's not required and not an array type
func ParamToValidationCode ¶
ParamToValidationCode takes in a param and returns a list of parameter validation functions, each of which have a single return value, error
func PathItemOperations ¶
PathItemOperations converts a spec.PathItem to a map from HTTP operation (e.g., "GET") to spec.Operation.
func SingleSchemaedBodyParameter ¶
SingleSchemaedBodyParameter returns true if the operation has a single, schema'd body input. It also returns the name of the model (without "models.").
func SortedOperationsKeys ¶
SortedOperationsKeys sorts the keys of a map[string]*spec.Operation.
func SortedPathItemKeys ¶
SortedPathItemKeys sorts the keys of a map[string]spec.PathItem.
func SortedStatusCodeKeys ¶
SortedStatusCodeKeys sorts the keys of a map[int]spec.Response.
func StringToTypeCode ¶
StringToTypeCode returns the code to convert a string into the type. For example, for an int64 it generates swag.ConvertFloat64(sizeStr). It returns an array because sometimes this takes multiple lines of code
func StructParamName ¶
StructParamName returns the name of the struct as used in the model struct
func TypeFromSchema ¶
TypeFromSchema returns the type of a Swagger schema as a string. If includeModels is true then it returns models.TYPE
Types ¶
type Generator ¶
type Generator struct { PackageName string // contains filtered or unexported fields }
Generator handles common code generation operations when generating a file in a Go package.