// RequiresNilCheck indicates whether the generated property should have a nil check performed on it before other checks.
// This should be used in templates when performing `nil` checks, but NOT when i.e. determining if there should be an optional pointer given to the type - in that case, use `HasOptionalPointer`
func (pProperty) RequiresNilCheck() bool {
returnp.ZeroValueIsNil() ||p.HasOptionalPointer()
}
// HasOptionalPointer indicates whether the generated property has an optional pointer associated with it.
// This takes into account the `x-go-type-skip-optional-pointer` extension, allowing a parameter definition to control whether the pointer should be skipped.
func (pProperty) HasOptionalPointer() bool {
return!p.Required&&!p.Schema.SkipOptionalPointer
}
// IsPointer reports whether the generated Go field for this property is
// pointer-typed, i.e. GoTypeDef renders with a leading `*`. Templates use it
// when assigning a value to the field requires taking an address first.
func (pProperty) IsPointer() bool {
returnstrings.HasPrefix(p.GoTypeDef(), "*")
}
// ZeroValueIsNil is a helper function to determine if the given Go type used
// for this property has `nil` as its Go zero value. Slices (OpenAPI `array`)
// and maps (OpenAPI `object` with only `additionalProperties`, rendered as
// `map[K]V`) both satisfy this — the custom-marshal templates use it to decide
// whether to emit a nil-check before reading the field.