go-swagger: github.com/go-swagger/go-swagger/cmd/swagger/commands Index | Files | Directories

package commands

import "github.com/go-swagger/go-swagger/cmd/swagger/commands"

Index

Package Files

diff.go expand.go flatten.go generate.go initcmd.go mixin.go serve.go validate.go version.go

Constants

const JSONFormat = "json"

JSONFormat for json

Variables

var (
    // Version for the swagger command
    Version string
    // Commit for the swagger command
    Commit string
)

type DiffCommand Uses

type DiffCommand struct {
    OnlyBreakingChanges bool   `long:"break" short:"b" description:"When present, only shows incompatible changes"`
    Format              string `long:"format" short:"f" description:"When present, writes output as json" default:"txt" choice:"txt" choice:"json"`
    IgnoreFile          string `long:"ignore" short:"i" description:"Exception file of diffs to ignore (copy output from json diff format)"  default:"none specified"`
    Destination         string `long:"dest" short:"d" description:"Output destination file or stdout" default:"stdout"`
}

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

There are no specific options for this expansion.

func (*DiffCommand) Execute Uses

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

Execute diffs the two specs provided

type ExpandSpec Uses

type ExpandSpec struct {
    Compact bool           `long:"compact" description:"applies to JSON formatted specs. When present, doesn't prettify the json"`
    Output  flags.Filename `long:"output" short:"o" description:"the file to write to"`
    Format  string         `long:"format" description:"the format for the spec document" default:"json" choice:"yaml" choice:"json"`
}

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

There are no specific options for this expansion.

func (*ExpandSpec) Execute Uses

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

Execute expands the spec

type FlattenSpec Uses

type FlattenSpec struct {
    Compact bool           `long:"compact" description:"applies to JSON formatted specs. When present, doesn't prettify the json"`
    Output  flags.Filename `long:"output" short:"o" description:"the file to write to"`
    Format  string         `long:"format" description:"the format for the spec document" default:"json" choice:"yaml" choice:"json"`
    generate.FlattenCmdOptions
}

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 Uses

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

Execute flattens the spec

type Generate Uses

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"`
}

Generate command to group all generator commands together

type InitCmd Uses

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

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

func (*InitCmd) Execute Uses

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

Execute provides default empty implementation

type MixinSpec Uses

type MixinSpec struct {
    ExpectedCollisionCount uint           `short:"c" description:"expected # of rejected mixin paths, defs, etc due to existing key. Non-zero exit if does not match actual."`
    Compact                bool           `long:"compact" description:"applies to JSON formatted specs. When present, doesn't prettify the json"`
    Output                 flags.Filename `long:"output" short:"o" description:"the file to write to"`
    Format                 string         `long:"format" description:"the format for the spec document" default:"json" choice:"yaml" choice:"json"`
}

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 Uses

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 Uses

func (c *MixinSpec) MixinFiles(primaryFile string, mixinFiles []string, w 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 mixin process and any error.

type PrintVersion Uses

type PrintVersion struct {
}

PrintVersion the command

func (*PrintVersion) Execute Uses

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

Execute this command

type ServeCmd Uses

type ServeCmd struct {
    BasePath string `long:"base-path" description:"the base path to serve the spec and UI at"`
    Flavor   string `short:"F" long:"flavor" description:"the flavor of docs, can be swagger or redoc" default:"redoc" choice:"redoc" choice:"swagger"`
    DocURL   string `long:"doc-url" description:"override the url which takes a url query param to render the doc ui"`
    NoOpen   bool   `long:"no-open" description:"when present won't open the the browser to show the url"`
    NoUI     bool   `long:"no-ui" description:"when present, only the swagger spec will be served"`
    Port     int    `long:"port" short:"p" description:"the port to serve this site" env:"PORT"`
    Host     string `long:"host" description:"the interface to serve this site, defaults to 0.0.0.0" env:"HOST"`
}

ServeCmd to serve a swagger spec with docs ui

func (*ServeCmd) Execute Uses

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

Execute the serve command

type ValidateSpec Uses

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

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

func (*ValidateSpec) Execute Uses

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

Execute validates the spec

Directories

PathSynopsis
diff
generate
initcmd

Package commands imports 26 packages (graph) and is imported by 3 packages. Updated 2019-08-14. Refresh now. Tools for package owners.