Documentation
¶
Overview ¶
Package openapi embeds and encapsulates the the current OpenAPITools openapi-generator-cli JAR file (see JAR constant for current version). This allows all of its commands and functionality to be used from any Go program easily with a single import (provided Java has been installed on the host system). The Run function passes all arguments directly to the embedded (or cached) jar file itself. Note that the embedded JAR file does not consume any RAM when any function from this package is called since embeds are saved in the .rodata section of the ELF binary, for example.)
For those who prefer to use java directly, the JAR file is extracted at init time to the java.CacheDir (default: os.UserCacheDir/gojavacache) and can be used like any other jar file from that location until explicitly removed. The embedded jar file will not be extracted and cached if a file of the same name is already there.
Index ¶
Examples ¶
Constants ¶
const JAR = "openapi-generator-cli-6.0.1.jar"
Variables ¶
var Cmd = &Z.Cmd{ Name: `openapi`, Summary: `encapsulated {{jar}}`, Version: `v0.1.0`, Copyright: `Copyright 2021 rwxrob/openapi Authors`, License: `Apache-2.0`, Source: `git@github.com:rwxrob/openapi.git`, Issues: `github.com/rwxrob/openapi/issues`, Commands: []*Z.Cmd{ help.Cmd, runCmd, genGinCmd, validateCmd, }, Description: ` The **{{.Name}}** command encapsulates and extends the commands available from the openapitools/openapi-generator-cli. Most will use the {{pre "run"}} command to pass arguments directly to the embedded/cached jar file. For convenience, additional command aliases have been added and all jar commands have been added as parameters so that bash tab completion will work. Embedded JAR The {{jar}} file is embedded into this command and package but does not occupy RAM. It is extracted and cached into {{cachedir}} at init time whenever this command (or any subcommand is executed). Dependencies This command obviously depends on {{pre "java"}} being installed before running it. The openapi-generator-cli requires version 1.8 or higher. A Dockerfile is available with the source of this command for those who wish to bundle a specific version of Java with this command. `}
Functions ¶
func GenGin ¶ added in v0.1.0
GenGin generates a Go Gin server using the go-gin-server generator taking a single path or URL as input and creating the directory specified (out) for output.
func Run ¶
Run passes all arguments directly to the JAR file. This function is the most important and is called by most other functions in this package (which is primarily just an encapsulation of that JAR file).
Example ¶
package main import ( "github.com/rwxrob/openapi" ) func main() { openapi.Run("version") }
Output: 6.0.1
Types ¶
This section is empty.