Documentation
¶
Index ¶
- func ApplyPatch(input []byte, patchFiles []PatchConfig) ([]byte, error)
- func ApplyPatchFromRawJSON(input []byte, patchFiles []PatchConfig) ([]byte, error)
- func ApplyPatchToRestSchema(input *schema.NDCRestSchema, patchFiles []PatchConfig) (*schema.NDCRestSchema, error)
- func MarshalSchema(content any, format schema.SchemaFileFormat) ([]byte, error)
- func ReadFileFromPath(filePath string) ([]byte, error)
- func ResolveFilePath(dir string, filePath string) string
- 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 ToCamelCase(input string) string
- func ToConstantCase(input string) string
- func ToPascalCase(input string) string
- func ToSnakeCase(input string) string
- func WalkFiles(filePath string, callback func(data []byte) error) error
- func WriteSchemaFile(outputPath string, content any) error
- type PatchConfig
- type PatchStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyPatch ¶ added in v0.2.0
func ApplyPatch(input []byte, patchFiles []PatchConfig) ([]byte, error)
ApplyPatch applies patches to the raw bytes input
func ApplyPatchFromRawJSON ¶ added in v0.2.0
func ApplyPatchFromRawJSON(input []byte, patchFiles []PatchConfig) ([]byte, error)
ApplyPatchFromRawJSON applies patches to the raw JSON bytes input without validation request
func ApplyPatchToRestSchema ¶ added in v0.2.0
func ApplyPatchToRestSchema(input *schema.NDCRestSchema, patchFiles []PatchConfig) (*schema.NDCRestSchema, error)
ApplyPatchToRestSchema applies JSON patches to NDC rest schema and validate the output
func MarshalSchema ¶
func MarshalSchema(content any, format schema.SchemaFileFormat) ([]byte, error)
MarshalSchema encodes the NDC REST schema to bytes
func ReadFileFromPath ¶
ReadFileFromPath read file content from either file path or URL
func ResolveFilePath ¶ added in v0.2.0
ResolveFilePath resolves file path with directory
func SliceUnorderedEqual ¶
SliceUnorderedEqual compares if both slices are equal with unordered positions
func SplitStringsAndTrimSpaces ¶
SplitStrings wrap strings.Split with all leading and trailing white space removed
func StringSliceToCamelCase ¶ added in v0.2.5
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 ToConstantCase ¶
ToConstantCase converts string to CONSTANT_CASE
func ToPascalCase ¶
ToPascalCase convert a string to PascalCase
func WalkFiles ¶ added in v0.2.0
WalkFiles read one file or many files in a folder if the file path is a directory
func WriteSchemaFile ¶
WriteSchemaFile writes the NDC REST schema to file
Types ¶
type PatchConfig ¶ added in v0.2.0
type PatchConfig struct { Path string `json:"path" yaml:"path"` Strategy PatchStrategy `json:"strategy" yaml:"strategy" jsonschema:"enum=merge,enum=json6902"` }
PatchConfig the configuration for JSON patch
type PatchStrategy ¶ added in v0.2.0
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" )