bindings

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package bindings wires generated platform-cmd subcommands to cobra flags and JSON request bodies. Two entry points:

  • DefineQueryFlags walks an oapi-codegen `*<Op>Params` struct and registers one cobra flag per field, supporting the pointer-of-scalar shape that oapi-codegen always emits for optional query parameters.
  • LoadJSONBody parses a `--json-body` argument (either inline JSON or `@path/to/file.json`) into the operation's request-body struct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefineQueryFlags

func DefineQueryFlags(cmd *cobra.Command, params any)

DefineQueryFlags registers one flag per exported field of *params. Fields must be pointer-to-scalar (or `[]string`, or `*[]string`) — anything else is skipped silently to keep the generated --help readable. Flag names are kebab-case of the JSON tag; descriptions come from the field's Go doc comment if present.

Hidden flag policy: query params that exist only to satisfy the OpenAPI security scheme (`access_token`) are auto-hidden so operators don't think they're meant to use them — auth flows through the bearer header.

func LoadJSONBody

func LoadJSONBody(arg string, dst any) error

LoadJSONBody parses `arg` into the value pointed to by dst.

  • "@path/to/file.json" reads the file.
  • Anything else is treated as a literal JSON string.
  • Empty arg leaves dst at its zero value (useful for body-less POSTs where the server still tolerates an empty object).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL