commands

package
v0.33.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 27 Imported by: 82

Documentation

Index

Constants

View Source
const JSONFormat = "json"

JSONFormat for json.

Variables

View Source
var (
	// Version for the swagger command.
	Version string
	// Commit for the swagger command.
	Commit string
)

Functions

This section is empty.

Types

type DiffCommand added in v0.20.0

type DiffCommand struct {
	OnlyBreakingChanges bool   `` /* 153-byte string literal not displayed */
	Format              string `` /* 231-byte string literal not displayed */
	IgnoreFile          string `` /* 167-byte string literal not displayed */
	Destination         string `` /* 167-byte string literal not displayed */
	Args                struct {
		OldSpec string `positional-arg-name:"{old spec}"`
		NewSpec string `positional-arg-name:"{new spec}"`
	} `required:"2" positional-args:"specs" description:"Input specs to be diff-ed"`
}

DiffCommand is a command that generates the diff of two swagger specs.

There are no specific options for this expansion.

func (*DiffCommand) Execute added in v0.20.0

func (c *DiffCommand) Execute(_ []string) error

Execute diffs the two specs provided.

type ExpandSpec added in v0.17.0

type ExpandSpec struct {
	Compact bool           `description:"applies to JSON formatted specs. When present, doesn't prettify the json" long:"compact"`
	Output  flags.Filename `description:"the file to write to"                                                     long:"output"  short:"o"`
	Format  string         `` /* 177-byte string literal not displayed */
}

ExpandSpec is a command that expands the $refs in a swagger document.

There are no specific options for this expansion.

func (*ExpandSpec) Execute added in v0.17.0

func (c *ExpandSpec) Execute(args []string) error

Execute expands the spec.

type FlattenSpec added in v0.17.0

type FlattenSpec struct {
	generate.FlattenCmdOptions

	Compact bool           `description:"applies to JSON formatted specs. When present, doesn't prettify the json" long:"compact"`
	Output  flags.Filename `description:"the file to write to"                                                     long:"output"  short:"o"`
	Format  string         `` /* 177-byte string literal not displayed */
}

FlattenSpec is a command that flattens a swagger document which will expand the remote references in a spec and move inline schemas to definitions after flattening there are no complex inlined anymore.

func (*FlattenSpec) Execute added in v0.17.0

func (c *FlattenSpec) Execute(args []string) error

Execute flattens the spec.

type Generate

type Generate struct {
	Model     *generate.Model     `command:"model"`
	Operation *generate.Operation `command:"operation"`
	Support   *generate.Support   `command:"support"`
	Server    *generate.Server    `command:"server"`
	Spec      *generate.SpecFile  `command:"spec"`
	Client    *generate.Client    `command:"client"`
	Cli       *generate.Cli       `command:"cli"`
	Markdown  *generate.Markdown  `command:"markdown"`
}

Generate command to group all generator commands together.

type InitCmd added in v0.17.0

type InitCmd struct {
	Model *initcmd.Spec `command:"spec"`
}

InitCmd is a command namespace for initializing things like a swagger spec.

func (*InitCmd) Execute added in v0.17.0

func (i *InitCmd) Execute(_ []string) error

Execute provides default empty implementation.

type MixinSpec added in v0.17.0

type MixinSpec struct {
	ExpectedCollisionCount uint           `` /* 130-byte string literal not displayed */
	Compact                bool           `` /* 135-byte string literal not displayed */
	Output                 flags.Filename `` /* 154-byte string literal not displayed */
	KeepSpecOrder          bool           `` /* 143-byte string literal not displayed */
	Format                 string         `` /* 220-byte string literal not displayed */
	IgnoreConflicts        bool           `` /* 144-byte string literal not displayed */
}

MixinSpec holds command line flag definitions specific to the mixin command. The flags are defined using struct field tags with the "github.com/jessevdk/go-flags" format.

func (*MixinSpec) Execute added in v0.17.0

func (c *MixinSpec) Execute(args []string) error

Execute runs the mixin command which merges Swagger 2.0 specs into one spec

Use cases include adding independently versioned metadata APIs to application APIs for microservices.

Typically, multiple APIs to the same service instance is not a problem for client generation as you can create more than one client to the service from the same calling process (one for each API). However, merging clients can improve clarity of client code by having a single client to given service vs several.

Server skeleton generation, ie generating the model & marshaling code, http server instance etc. from Swagger, becomes easier with a merged spec for some tools & target-languages. Server code generation tools that natively support hosting multiple specs in one server process will not need this tool.

func (*MixinSpec) MixinFiles added in v0.17.0

func (c *MixinSpec) MixinFiles(primaryFile string, mixinFiles []string, _ io.Writer) ([]string, error)

MixinFiles is a convenience function for Mixin that reads the given swagger files, adds the mixins to primary, calls FixEmptyResponseDescriptions on the primary, and writes the primary with mixins to the given writer in JSON.

Returns the warning messages for collisions that occurred during the mixin process and any error.

type PrintVersion added in v0.17.0

type PrintVersion struct{}

PrintVersion the command.

func (*PrintVersion) Execute added in v0.17.0

func (p *PrintVersion) Execute(_ []string) error

Execute this command.

type ServeCmd added in v0.17.0

type ServeCmd struct {
	BasePath string `description:"the base path to serve the spec and UI at"                           long:"base-path"`
	Flavor   string `` /* 247-byte string literal not displayed */
	DocURL   string `description:"override the url which takes a url query param to render the doc ui" long:"doc-url"`
	NoOpen   bool   `description:"when present won't open the browser to show the url"                 long:"no-open"`
	NoUI     bool   `description:"when present, only the swagger spec will be served"                  long:"no-ui"`
	Flatten  bool   `description:"when present, flatten the swagger spec before serving it"            long:"flatten"`
	Port     int    `` /* 175-byte string literal not displayed */
	Host     string `` /* 177-byte string literal not displayed */
	Path     string `` /* 161-byte string literal not displayed */
}

ServeCmd to serve a swagger spec with docs ui.

func (*ServeCmd) Execute added in v0.17.0

func (s *ServeCmd) Execute(args []string) error

Execute the serve command.

type ValidateSpec

type ValidateSpec struct {
	// SchemaURL string `long:"schema" description:"The schema url to use" default:"http://swagger.io/v2/schema.json"`
	SkipWarnings bool `description:"when present will not show up warnings upon validation"                    long:"skip-warnings"`
	StopOnError  bool `description:"when present will not continue validation after critical errors are found" long:"stop-on-error"`
}

ValidateSpec is a command that validates a swagger document against the swagger specification.

func (*ValidateSpec) Execute

func (c *ValidateSpec) Execute(args []string) error

Execute validates the spec.

Directories

Path Synopsis
internal
cmdtest
Package cmdtest provides test utilities to assert the output of CLI commands
Package cmdtest provides test utilities to assert the output of CLI commands

Jump to

Keyboard shortcuts

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