github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/cmd/swagger/completion/swagger.zsh-completion (about) 1 #compdef swagger 2 3 local context state state_descr line 4 typeset -A opt_args 5 6 __expand() { 7 _arguments \ 8 '(-h,--help)'{-h,--help}'[Print help message]' \ 9 "(--compact)--compact[when present, doesn't prettify the json]" \ 10 '(-o, --output)'{-o,--output}"[the file to write to]:output" && return 0 11 } 12 13 __flatten() { 14 _arguments \ 15 '(-h,--help)'{-h,--help}'[Print help message]' \ 16 "(--compact)--compact[when present, doesn't prettify the the json]" \ 17 '(-o, --output)'{-o,--output}"[the file to write to]:output" && return 0 18 } 19 20 __generate_client() { 21 _arguments \ 22 '(-h,--help)'{-h,--help}'[Print help message]' \ 23 '(-f,--spec)'{-f,--spec}"[the spec file to use (default:swagger.{json,yml,yaml)]:spec" \ 24 '(-a,--api-package)'{-a,--api-package}"[the package to save the operations (default:operations)]:api-package" \ 25 '(-m,--model-package)'{-m,--model-package}"[the package to save the models (default: models)]:model-package" \ 26 '(-s,--server-package)'{-s,--server-package}"[the package to save the server specific code (default: restapi)]:server-package" \ 27 '(-c,--client-package)'{-c,--client-package}"[the package to save the client specific code (default: client)]:client-package" \ 28 '(-t,--target)'{-t,--target}"[the base directory for generating the files (default: ./)]:target" \ 29 '(-T,--template-dir)'{-T,--template-dir}"[alternative template override directory]:template-dir" \ 30 '(-C,--config-file)'{-C,--config-file}"[configuration file to use for overriding template options]:config-file" \ 31 '(-A,--name)'{-A,--name}"[the name of the application, defaults to a mangled value of info.title]:name" \ 32 '(-O,--operation)'{-O,--operation}"[specify an operation to include, repeat for multiple]:operation" \ 33 '(--tags)'--tags"[the tags to include, if not specified defaults to all]:tags" \ 34 '(-P,--principal)'{-P,--principal}"[the model to use for the security principal]:principal" \ 35 '(-M,--model)'{-M,--model}"[specify a model to include, repeat for multiple]:model" \ 36 '(--default-scheme)'--default-scheme"[the default scheme for this client (default: http)]:default-scheme" \ 37 '(--default-produces)'--default-produces"[the default mime type that API operations produce (default: application/json)]:default-produces" \ 38 '(--skip-models)'--skip-models"[no models will be generated when this flag is specified]" \ 39 '(--skip-operations)'--skip-operations"[no operations will be generated when this flag is specified]" \ 40 '(--dump-data)'--dump-data"[when present dumps the json for the template generator instead of generating files]" \ 41 '(--skip-validation)'--skip-validation"[skips validation of spec prior to generation]" && return 0 42 } 43 44 __generate_model() { 45 _arguments \ 46 '(-h,--help)'{-h,--help}'[Print help message]' \ 47 '(-f,--spec)'{-f,--spec}"[the spec file to use (default swagger.{json,yml,yaml})]:spec" \ 48 '(-a,--api-package)'{-a,--api-package}"[the package to save the operations (default: operations)]:api-package" \ 49 '(-m,--model-package)'{-m,--model-package}"[the package to save the models (default: models)]:model-package" \ 50 '(-s,--server-package)'{-s,--server-package}"[the package to save the server specific code (default: restapi)]:server-package" \ 51 '(-c,--client-package)'{-c,--client-package}"[the package to save the client specific code (default: client)]:client-package" \ 52 '(-t,--target)'{-t,--target}"[the base directory for generating the files (default: ./)]:target" \ 53 '(-T,--template-dir)'{-T,--template-dir}"[alternative template override directory]:template-dir" \ 54 '(-C,--config-file)'{-C,--config-file}"[configuration file to use for overriding template options]:config-file" \ 55 '(-n,--name)'{-n,--name}"[the model to generate]:name" \ 56 "(--skip-struct)--skip-struct[when present will not generate the model struct]" \ 57 "(--dump-data)--dump-data[when present dumps the json for the template generator instead of generating files]" && return 0 58 } 59 60 __generate_operation() { 61 _arguments \ 62 '(-h,--help)'{-h,--help}'[Print help message]' \ 63 '(-f,--spec)'{-f,--spec}"[the spec file to use (default swagger.{json,yml,yaml})]:spec" \ 64 '(-a,--api-package)'{-a,--api-package}"[the package to save the operations (default: operations)]:api-package" \ 65 '(-m,--model-package)'{-m,--model-package}"[the package to save the models (default: models)]:model-package" \ 66 '(-s,--server-package)'{-s,--server-package}"[the package to save the server specific code (default: restapi)]:server-package" \ 67 '(-c,--client-package)'{-c,--client-package}"[the package to save the client specific code (default: client)]:client-package" \ 68 '(-t,--target)'{-t,--target}"[the base directory for generating the files (default: ./)]:target" \ 69 '(-T,--template-dir)'{-T,--template-dir}"[alternative template override directory]:template-dir" \ 70 '(-C,--config-file)'{-C,--config-file}"[configuration file to use for overriding template options]:config-file" \ 71 '(-n,--name)'{-n,--name}"[the operations to generate, repeat for multiple]:name" \ 72 "(--tags)--tags[the tags to include, if not specified defaults to all]:tags" \ 73 '(-P,--principal)'{-P,--principal}"[the model to use for the security principal]:principal" \ 74 "(--default-scheme)--default-scheme[the default scheme for this API (default: http)]:default-scheme" \ 75 "(--skip-handler)--skip-handler[when present will not generate an operation handler]" \ 76 "(--skip-parameters)--skip-parameters[when present will not generate the parameter model struct]" \ 77 "(--skip-responses)--skip-responses[when present will not generate the response model struct]" \ 78 "(--skip-url-builder)--skip-url-builder[when present will not generate a URL builder]" \ 79 "(--dump-data)--dump-data[when present dumps the json for the template generator instead of generating files]" && return 0 80 } 81 82 __generate_server() { 83 _arguments \ 84 '(-h,--help)'{-h,--help}'[Print help message]' \ 85 '(-f,--spec)'{-f,--spec}"[the spec file to use (default swagger.{json,yml,yaml})]:spec" \ 86 '(-a,--api-package)'{-a,--api-package}"[the package to save the operations (default: operations)]:api-package" \ 87 '(-m,--model-package)'{-m,--model-package}"[the package to save the models (default: models)]:model-package" \ 88 '(-s,--server-package)'{-s,--server-package}"[the package to save the server specific code (default: restapi)]:server-package" \ 89 '(-c,--client-package)'{-c,--client-package}"[the package to save the client specific code (default: client)]:client-package" \ 90 '(-t,--target)'{-t,--target}"[the base directory for generating the files (default: ./)]:target" \ 91 '(-T,--template-dir)'{-T,--template-dir}"[alternative template override directory]:template-dir" \ 92 '(-C,--config-file)'{-C,--config-file}"[configuration file to use for overriding template options]:config-file" \ 93 '(-A,--name)'{-A,--name}"[the name of the application, defaults to a mangled value of info.title]:name" \ 94 '(-O,--operation)'{-O,--operation}"[specify an operation to include, repeat for multiple]:operations" \ 95 "(--tags)--tags[the tags to include, if not specified defaults to all]:tags" \ 96 '(-P,--principal)'{-P,--principal}"[the model to use for the security principal]:principal" \ 97 "(--default-scheme)--default-scheme[the default scheme for this API (default: http)]:default-scheme" \ 98 '(-M,--model)'{-M,--model}"[specify a model to include, repeat for multiple]:model" \ 99 "(--skip-models)--skip-models[no models will be generated when this flag is specified]" \ 100 "(--skip-operations)--skip-operations[no operations will be generated when this flag is specified]" \ 101 "(--skip-support)--skip-support[no supporting files will be generated when this flag is specified]" \ 102 "(--exclude-main)--exclude-main[exclude main function, so just generate the library]" \ 103 "(--exclude-spec)--exclude-spec[don't embed the swagger specification]" \ 104 "(--with-context)--with-context[handlers get a context as first arg]" \ 105 "(--dump-data)--dump-data[when present dumps the json for the template generator instead of generating files]" \ 106 "(--flag-strategy)--flag-strategy[the strategy to provide flags for the server (default: go-flags)]:flag-strategy:(go-flags pflag)" \ 107 "(--compatibility-mode)--compatibility-mode[the compatibility mode for the tls server (default: modern)]:compatibility-mode:(modern intermediate)" \ 108 "(--skip-validation)--skip-validation[skips validation of spec prior to generation]" && return 0 109 } 110 111 __generate_spec() { 112 _arguments \ 113 '(-h,--help)'{-h,--help}'[Print help message]' \ 114 '(-w,--work-dir)'{-w,--work-dir}"[the base path to use (default: .)]:work-dir" \ 115 '(-m,--scan-models)'{-m,--scan-models}"[includes models that were annotated with 'swagger:model']" \ 116 "(--compact)--compact[when present, doesn't prettify the the json]" \ 117 '(-o,--output)'{-o,--output}"[the file to write to]:output" \ 118 '(-i,--input)'{-i,--input}"[an input swagger file with which to merge]:input" && return 0 119 } 120 121 __generate_support() { 122 _arguments \ 123 '(-h,--help)'{-h,--help}'[Print help message]' \ 124 '(-f,--spec)'{-f,--spec}"[the spec file to use (default swagger.{json,yml,yaml})]:spec" \ 125 '(-a,--api-package)'{-a,--api-package}"[the package to save the operations (default: operations)]:api-package" \ 126 '(-m,--model-package)'{-m,--model-package}"[the package to save the models (default: models)]:model-package" \ 127 '(-s,--server-package)'{-s,--server-package}"[the package to save the server specific code (default: restapi)]:server-package" \ 128 '(-c,--client-package)'{-c,--client-package}"[the package to save the client specific code (default: client)]:client-package" \ 129 '(-t,--target)'{-t,--target}"[the base directory for generating the files (default: ./)]:target" \ 130 '(-T,--template-dir)'{-T,--template-dir}"[alternative template override directory]:template-dir" \ 131 '(-C,--config-file)'{-C,--config-file}"[configuration file to use for overriding template options]:config-file" \ 132 '(-A,--name)'{-A,--name}"[the name of the application, defaults to a mangled value of info.title]:name" \ 133 '(-O,--operation)'{-O,--operation}"[specify an operation to include, repeat for multiple]:operation" \ 134 "(--principal)--principal[the model to use for the security principal]:principal" \ 135 '(-M,--model)'{-M,--model}"[specify a model to include, repeat for multiple]:model" \ 136 "(--dump-data)--dump-data[when present dumps the json for the template generator instead of generating files]" \ 137 "(--default-scheme)--default-scheme[the default scheme for this API (default: http)]:default-scheme" && return 0 138 } 139 140 __generate() { 141 local commands 142 commands=( 143 'client:generate all the files for a client library' 144 'model:generate one or more models from the swagger spec' 145 'operation:generate one or more server operations from the swagger spec' 146 'server:generate all the files for a server application' 147 'spec:generate a swagger spec document from a go application' 148 'support:generate supporting files like the main function and the api builder' 149 ) 150 151 _arguments \ 152 '(-h,--help)'{-h,--help}'[Print help message]' \ 153 '*:: :->subcmds' && return 0 154 155 if (( CURRENT == 1 )); then 156 _describe -t commands "swagger generate subcommand" commands 157 return 158 fi 159 160 case "$words[1]" in 161 client) 162 __generate_client ;; 163 model) 164 __generate_model ;; 165 operation) 166 __generate_operation ;; 167 server) 168 __generate_server ;; 169 spec) 170 __generate_spec ;; 171 support) 172 __generate_support ;; 173 esac 174 } 175 176 __init_spec() { 177 _arguments \ 178 '(-h,--help)'{-h,--help}'[Print help message]' \ 179 "(--format)--format[the format for the spec document (default: yaml)]:format:(yaml json)" \ 180 "(--title)--title[the title of the API]:title" \ 181 "(--description)--description[the description of the API]:description" \ 182 "(--version)--version[the version of the API (default: 0.1.0)]:version" \ 183 "(--terms)--terms[the terms of services]:terms" \ 184 "(--consumes)--consumes[add a content type to the global consumes definitions, can repeat (default: application/json)]:consumes" \ 185 "(--produces)--produces[add a content type to the global produces definitions, can repeat (default: application/json)]:produces" \ 186 "(--scheme)--scheme[add a scheme to the global schemes definition, can repeat (default: http)]:scheme" \ 187 "(--contact.name)--contact.name[name of the primary contact for the API]:contact.name" \ 188 "(--contact.url)--contact.url[url of the primary contact for the API]:contact.url" \ 189 "(--contact.email)--contact.email[email of the primary contact for the API]:contact.email" \ 190 "(--license.name)--license.name[name of the license for the API]:license.name" \ 191 "(--license.url)--license.url[url of the license for the API]:license.url" && return 0 192 } 193 194 __init() { 195 local commands 196 commands=( 197 'spec:' 198 ) 199 200 _arguments \ 201 '(-h,--help)'{-h,--help}'[Print help message]' \ 202 '*:: :->subcmds' && return 0 203 204 if (( CURRENT == 1 )); then 205 _describe -t commands "swagger spec subcommand" commands 206 return 207 fi 208 209 case "$words[1]" in 210 spec) 211 __init_spec ;; 212 esac 213 } 214 215 __serve() { 216 _arguments \ 217 '(-h,--help)'{-h,--help}'[Print help message]' \ 218 "(--base-path)--base-path[the base path to serve the spec and UI at]:base-path" \ 219 '(-F,--flavor)'{-F,--flavor}"[the flavor of docs, can be swagger or redoc (default: redoc)]:flavor:(redoc swagger)" \ 220 "(--doc-url)--doc-url[override the url which takes a url query param to render the doc ui]:doc-url" \ 221 "(--no-open)--no-open[when present won't open the the browser to show the url]" \ 222 "(--no-ui)--no-ui[when present, only the swagger spec will be served]" \ 223 '(-p,--port)'{-p,--port}'[the port to serve this site (default:$PORT)]:port' \ 224 '(--host)--host[the interface to serve this site, defaults to 0.0.0.0 (default:$HOST)]:host' && return 0 225 } 226 227 __validate() { 228 _arguments \ 229 '(-h,--help)'{-h,--help}'[Print help message]' && return 0 230 } 231 232 __version() { 233 _arguments \ 234 '(-h,--help)'{-h,--help}'[Print help message]' && return 0 235 } 236 237 # swagger tool 238 _swagger_complete() { 239 local commands 240 commands=( 241 'expand:expand $ref fields in a swagger spec' 242 'flatten:flattens a swagger document' 243 'generate:generate go code' 244 'init:initialize a spec document' 245 'serve:serve spec and docs' 246 'validate:validate the swagger document' 247 'version:print the version' 248 ) 249 250 _arguments \ 251 '(-h,--help)'{-h,--help}'[Print help message]' \ 252 '*:: :->subcmds' && return 0 253 254 if (( CURRENT == 1 )); then 255 _describe -t commands "swagger subcommand" commands 256 return 257 fi 258 259 case "$words[1]" in 260 expand) 261 __expand ;; 262 flatten) 263 __flatten ;; 264 generate) 265 __generate ;; 266 init) 267 __init ;; 268 serve) 269 __serve ;; 270 validate) 271 __validate ;; 272 version) 273 __version ;; 274 esac 275 } 276 277 compdef _swagger_complete swagger