Documentation
¶
Index ¶
- func ApplyPatch(input []byte, patchFiles []PatchConfig) ([]byte, error)
- func ApplyPatchFromRawJSON(input []byte, patchFiles []PatchConfig) ([]byte, error)
- func ApplyPatchToHTTPSchema(input *schema.NDCHttpSchema, patchFiles []PatchConfig) (*schema.NDCHttpSchema, error)
- func BuildUniqueSchemaTypeName(sm *rest.NDCHttpSchema, name string) string
- func CloneURL(input *url.URL) *url.URL
- func IsContentTypeBinary(contentType string) bool
- func IsContentTypeJSON(contentType string) bool
- func IsContentTypeMultipartForm(contentType string) bool
- func IsContentTypeText(contentType string) bool
- func IsContentTypeXML(contentType string) bool
- func IsNullableTypeEncoder(input schema.TypeEncoder) bool
- func MarshalSchema(content any, format schema.SchemaFileFormat) ([]byte, error)
- func MaskString(input string) string
- func ReadFileFromPath(filePath string) ([]byte, error)
- func RemoveYAMLSpecialCharacters(input []byte) string
- func ResolveFilePath(dir string, filePath string) string
- func SliceUnique[T cmp.Ordered](input []T) []T
- func SliceUnorderedEqual[T cmp.Ordered](a []T, b []T) bool
- func SplitStringsAndTrimSpaces(input string, sep string) []string
- func StringSliceToCamelCase(inputs []string) string
- func StringSliceToConstantCase(inputs []string) string
- func StringSliceToPascalCase(inputs []string) string
- func StringSliceToSnakeCase(inputs []string) string
- func StripHTMLTags(str string) string
- func ToCamelCase(input string) string
- func ToConstantCase(input string) string
- func ToPascalCase(input string) string
- func ToSnakeCase(input string) string
- func UnwrapNullableType(input schema.Type) (schema.TypeEncoder, bool, error)
- func UnwrapNullableTypeEncoder(input schema.TypeEncoder) (schema.TypeEncoder, bool, error)
- func WalkFiles(filePath string, callback func(data []byte) error) error
- func WrapNullableTypeEncoder(input schema.TypeEncoder) schema.TypeEncoder
- func WriteSchemaFile(outputPath string, content any) error
- type PatchConfig
- type PatchStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyPatch ¶
func ApplyPatch(input []byte, patchFiles []PatchConfig) ([]byte, error)
ApplyPatch applies patches to the raw bytes input.
func ApplyPatchFromRawJSON ¶
func ApplyPatchFromRawJSON(input []byte, patchFiles []PatchConfig) ([]byte, error)
ApplyPatchFromRawJSON applies patches to the raw JSON bytes input without validation request.
func ApplyPatchToHTTPSchema ¶
func ApplyPatchToHTTPSchema( input *schema.NDCHttpSchema, patchFiles []PatchConfig, ) (*schema.NDCHttpSchema, error)
ApplyPatchToHTTPSchema applies JSON patches to NDC HTTP schema and validate the output.
func BuildUniqueSchemaTypeName ¶
func BuildUniqueSchemaTypeName(sm *rest.NDCHttpSchema, name string) string
BuildUniqueSchemaTypeName builds the unique type name from schema.
func IsContentTypeBinary ¶
IsContentTypeBinary checks if the content type relates to binary.
func IsContentTypeJSON ¶
IsContentTypeJSON checks if the content type is JSON.
func IsContentTypeMultipartForm ¶
IsContentTypeMultipartForm checks the content type relates to multipart form.
func IsContentTypeText ¶
IsContentTypeText checks if the content type relates to text.
func IsContentTypeXML ¶
IsContentTypeXML checks if the content type is XML.
func IsNullableTypeEncoder ¶
func IsNullableTypeEncoder(input schema.TypeEncoder) bool
IsNullableTypeEncoder checks if the input type is nullable.
func MarshalSchema ¶
func MarshalSchema(content any, format schema.SchemaFileFormat) ([]byte, error)
MarshalSchema encodes the NDC HTTP schema to bytes.
func MaskString ¶
MaskString masks the string value for security.
func ReadFileFromPath ¶
ReadFileFromPath read file content from either file path or URL.
func RemoveYAMLSpecialCharacters ¶
RemoveYAMLSpecialCharacters remote special characters to avoid YAML unmarshaling error.
func ResolveFilePath ¶
ResolveFilePath resolves file path with directory.
func SliceUnique ¶
SliceUnique gets unique elements of the input slice.
func SliceUnorderedEqual ¶
SliceUnorderedEqual compares if both slices are equal with unordered positions.
func SplitStringsAndTrimSpaces ¶
SplitStringsAndTrimSpaces wrap strings.Split with all leading and trailing white space removed.
func StringSliceToCamelCase ¶
StringSliceToCamelCase convert a slice of strings to camelCase.
func StringSliceToConstantCase ¶
StringSliceToConstantCase convert a slice of string to CONSTANT_CASE.
func StringSliceToPascalCase ¶
StringSliceToPascalCase convert a slice of string to PascalCase.
func StringSliceToSnakeCase ¶
StringSliceToSnakeCase convert a slice of string to snake_case.
func StripHTMLTags ¶
StripHTMLTags aggressively strips HTML tags from a string. It will only keep anything between `>` and `<`.
func ToConstantCase ¶
ToConstantCase converts string to CONSTANT_CASE.
func ToPascalCase ¶
ToPascalCase convert a string to PascalCase.
func UnwrapNullableType ¶
UnwrapNullableType unwraps the underlying type of the nullable type.
func UnwrapNullableTypeEncoder ¶
func UnwrapNullableTypeEncoder(input schema.TypeEncoder) (schema.TypeEncoder, bool, error)
UnwrapNullableTypeEncoder unwraps the underlying type of the nullable type.
func WrapNullableTypeEncoder ¶
func WrapNullableTypeEncoder(input schema.TypeEncoder) schema.TypeEncoder
WrapNullableTypeEncoder wraps the schema type with nullable.
func WriteSchemaFile ¶
WriteSchemaFile writes the NDC HTTP schema to file.
Types ¶
type PatchConfig ¶
type PatchConfig struct {
Path string `json:"path" yaml:"path"`
Strategy PatchStrategy `json:"strategy" yaml:"strategy" jsonschema:"enum=merge,enum=json6902,default=merge"`
}
PatchConfig the configuration for JSON patch.
type PatchStrategy ¶
type PatchStrategy string
PatchStrategy represents the patch strategy enum.
const ( // PatchStrategyMerge the merge strategy enum for [RFC 7396] specification // // [RFC 7396]: https://datatracker.ietf.org/doc/html/rfc7396 PatchStrategyMerge PatchStrategy = "merge" // PatchStrategyJSON6902 the patch strategy enum for [RFC 6902] specification // // [RFC 6902]: https://datatracker.ietf.org/doc/html/rfc6902 PatchStrategyJSON6902 PatchStrategy = "json6902" )