openapi

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README ¶

🌳 OpenAPITools from Go

This repo contains a Bonzai branch that lightly embeds and encapsulates the openapi-generator-cli JAR from the OpenAPITools project allowing it to be used as high-level programmatic API from Go, stand-alone openapi command, openapi subcommand within a Bonzai tree monolith, or just to conveniently acquire and cache the current openapi-generator-cli JAR file itself.

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 ¶

View Source
const JAR = "openapi-generator-cli-6.0.1.jar"

Variables ¶

View Source
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

func GenGin(in, out string) error

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 ¶

func Run(args ...string) error

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

func Validate ¶

func Validate(path string) error

Validate is a shortcut for Run("validate", "-i", path, "--recommend")

Types ¶

This section is empty.

Directories ¶

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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