Documentation
¶
Index ¶
- Constants
- Variables
- func AddExtension(ve *oaispec.VendorExtensible, key string, value any, skip bool)
- func FindASTField(file *ast.File, pos token.Pos) *ast.Field
- func GetEnumDesc(extensions oaispec.Extensions) string
- func IsAny(o *types.TypeName) bool
- func IsFieldStringable(tpe ast.Expr) bool
- func IsStdError(o *types.TypeName) bool
- func IsStdJSONRawMessage(o *types.TypeName) bool
- func IsStdTime(o *types.TypeName) bool
- func IsTextMarshaler(tpe types.Type) bool
- func MustBeAType(tpe types.TypeAndValue)
- func MustHaveRightHandSide(a *types.Alias)
- func MustNotBeABuiltinType(o *types.TypeName)
- func ParseJSONTag(field *ast.Field) (name string, ignore, isString, omitEmpty bool, err error)
- func SwaggerSchemaForType(typeName string, prop ifaces.SwaggerTypable) error
- func UnsupportedBasic(tpe *types.Basic) bool
- func UnsupportedBuiltin(tpe ifaces.Objecter) (skip bool)
- func UnsupportedBuiltinType(tpe types.Type) bool
- type ItemsTypable
- func (pt ItemsTypable) AddExtension(key string, value any)
- func (pt ItemsTypable) In() string
- func (pt ItemsTypable) Items() ifaces.SwaggerTypable
- func (pt ItemsTypable) Level() int
- func (pt ItemsTypable) Schema() *oaispec.Schema
- func (pt ItemsTypable) SetRef(ref oaispec.Ref)
- func (pt ItemsTypable) Typed(tpe, format string)
- func (pt ItemsTypable) WithEnum(values ...any)
- func (pt ItemsTypable) WithEnumDescription(_ string)
- type ItemsValidations
- func (sv ItemsValidations) SetCollectionFormat(val string)
- func (sv ItemsValidations) SetDefault(val any)
- func (sv ItemsValidations) SetEnum(val string)
- func (sv ItemsValidations) SetExample(val any)
- func (sv ItemsValidations) SetMaxItems(val int64)
- func (sv ItemsValidations) SetMaxLength(val int64)
- func (sv ItemsValidations) SetMaximum(val float64, exclusive bool)
- func (sv ItemsValidations) SetMinItems(val int64)
- func (sv ItemsValidations) SetMinLength(val int64)
- func (sv ItemsValidations) SetMinimum(val float64, exclusive bool)
- func (sv ItemsValidations) SetMultipleOf(val float64)
- func (sv ItemsValidations) SetPattern(val string)
- func (sv ItemsValidations) SetUnique(val bool)
Constants ¶
const (
ErrInternal internalError = "internal error due to a bug or a mishandling of go types AST. This usually indicates a bug in the scanner"
)
const ExtEnumDesc = "x-go-enum-desc"
ExtEnumDesc is the vendor-extension key the scanner uses to expose the per-enum-value documentation lines built from `swagger:enum` + const-block comments. It's a go-swagger concept (not part of the OpenAPI spec); the key lives in `resolvers` so every builder (schema, parameters, responses) reads and writes it through the same constant.
Variables ¶
var ErrResolver = errors.New("codescan:resolver")
ErrResolver is the sentinel error for all errors originating from the resolver package.
Functions ¶
func AddExtension ¶
func AddExtension(ve *oaispec.VendorExtensible, key string, value any, skip bool)
func GetEnumDesc ¶ added in v0.34.1
func GetEnumDesc(extensions oaispec.Extensions) string
GetEnumDesc reads the x-go-enum-desc extension off a Swagger extensions map. Empty when absent.
Consumers typically check this after a build pass to know whether they should append the per-value docs to a Description (parameters + response headers do this for the parameter/header description; the schema builder folds it in differently — see `handlers/dispatch_schema.go:clearStaleEnumDesc` for the override-cleanup dance).
func IsFieldStringable ¶
IsFieldStringable check if the field type is a scalar. If the field type is *ast.StarExpr and is pointer type, check if it refers to a scalar. Otherwise, the ",string" directive doesn't apply.
func IsStdError ¶
func IsStdJSONRawMessage ¶
func IsTextMarshaler ¶
func MustBeAType ¶ added in v0.34.1
func MustBeAType(tpe types.TypeAndValue)
func MustHaveRightHandSide ¶
func MustNotBeABuiltinType ¶
func ParseJSONTag ¶
func SwaggerSchemaForType ¶
func SwaggerSchemaForType(typeName string, prop ifaces.SwaggerTypable) error
SwaggerSchemaForType maps all Go builtin types that have Json representation to Swagger/Json types.
See https://golang.org/pkg/builtin/ and http://swagger.io/specification/
func UnsupportedBasic ¶
func UnsupportedBuiltin ¶
UnsupportedBuiltin returns true when tpe is unsafe.Pointer.
Other "unsupported builtins" (complex64, complex128) cannot reach this function: they surface as *types.Basic, which does not satisfy ifaces.Objecter. Those are caught one layer down by UnsupportedBasic / UnsupportedBuiltinType when the *types.Basic surfaces directly.
Supported builtins:
- error
func UnsupportedBuiltinType ¶
Types ¶
type ItemsTypable ¶ added in v0.34.1
type ItemsTypable struct {
// contains filtered or unexported fields
}
ItemsTypable adapts an *oaispec.Items target to ifaces.SwaggerTypable so the parameters/responses builders can recurse through nested array layers (SimpleSchema's items chain).
One adapter, two callers (parameters, responses); lives here because it's pure ifaces-glue with no builder-specific logic. The schema builder uses its own *oaispec.Schema.Items chain and has no need for this adapter.
func NewItemsTypable ¶ added in v0.34.1
func NewItemsTypable(items *oaispec.Items, level int, in string) ItemsTypable
func (ItemsTypable) AddExtension ¶ added in v0.34.1
func (pt ItemsTypable) AddExtension(key string, value any)
func (ItemsTypable) In ¶ added in v0.34.1
func (pt ItemsTypable) In() string
func (ItemsTypable) Items ¶ added in v0.34.1
func (pt ItemsTypable) Items() ifaces.SwaggerTypable
func (ItemsTypable) Level ¶ added in v0.34.1
func (pt ItemsTypable) Level() int
func (ItemsTypable) Schema ¶ added in v0.34.1
func (pt ItemsTypable) Schema() *oaispec.Schema
func (ItemsTypable) SetRef ¶ added in v0.34.1
func (pt ItemsTypable) SetRef(ref oaispec.Ref)
func (ItemsTypable) Typed ¶ added in v0.34.1
func (pt ItemsTypable) Typed(tpe, format string)
func (ItemsTypable) WithEnum ¶ added in v0.34.1
func (pt ItemsTypable) WithEnum(values ...any)
func (ItemsTypable) WithEnumDescription ¶ added in v0.34.1
func (pt ItemsTypable) WithEnumDescription(_ string)
type ItemsValidations ¶ added in v0.34.1
type ItemsValidations struct {
// contains filtered or unexported fields
}
ItemsValidations wraps an *oaispec.Items as a ValidationBuilder / OperationValidationBuilder target. Used by parameters' and responses' grammar items-level Walker dispatch.
func NewItemsValidations ¶ added in v0.34.1
func NewItemsValidations(it *oaispec.Items) ItemsValidations
func (ItemsValidations) SetCollectionFormat ¶ added in v0.34.1
func (sv ItemsValidations) SetCollectionFormat(val string)
func (ItemsValidations) SetDefault ¶ added in v0.34.1
func (sv ItemsValidations) SetDefault(val any)
func (ItemsValidations) SetEnum ¶ added in v0.34.1
func (sv ItemsValidations) SetEnum(val string)
func (ItemsValidations) SetExample ¶ added in v0.34.1
func (sv ItemsValidations) SetExample(val any)
func (ItemsValidations) SetMaxItems ¶ added in v0.34.1
func (sv ItemsValidations) SetMaxItems(val int64)
func (ItemsValidations) SetMaxLength ¶ added in v0.34.1
func (sv ItemsValidations) SetMaxLength(val int64)
func (ItemsValidations) SetMaximum ¶ added in v0.34.1
func (sv ItemsValidations) SetMaximum(val float64, exclusive bool)
func (ItemsValidations) SetMinItems ¶ added in v0.34.1
func (sv ItemsValidations) SetMinItems(val int64)
func (ItemsValidations) SetMinLength ¶ added in v0.34.1
func (sv ItemsValidations) SetMinLength(val int64)
func (ItemsValidations) SetMinimum ¶ added in v0.34.1
func (sv ItemsValidations) SetMinimum(val float64, exclusive bool)
func (ItemsValidations) SetMultipleOf ¶ added in v0.34.1
func (sv ItemsValidations) SetMultipleOf(val float64)
func (ItemsValidations) SetPattern ¶ added in v0.34.1
func (sv ItemsValidations) SetPattern(val string)
func (ItemsValidations) SetUnique ¶ added in v0.34.1
func (sv ItemsValidations) SetUnique(val bool)