arlong

package module
v0.0.0-...-64d1c2d Latest Latest
Warning

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

Go to latest
Published: May 25, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

README

Arlong godoc badge Build Status

Swagger 2.0 Generator

##Install

go get -u github.com/plimble/arlong/...

##Example

// @DefinitionModel
type Hello struct {
  // @Name ebola1
  // @Description ssssss
  // @Required
  E *Hello8

  // @Required
  A Hello8

  *Hello8
  test int

  // @Name -
  private int

  // @Required
  mapping map[string]int
}

// @Swagger
// @Title Api
// @Description Super api
// @Term Dont use
// @Contact name="John Doe" url=http://www.company.com email=johndoe@company.com
// @License name="Apache 2.0" url=http://google.com
// @Version 1.1.1
// @Schemes http https ws
// @Consumes json xml
// @Produces json xml
// @Security petstore_auth=write:pets,read:pets
//
// @SecurityDefinition petstore_auth
// @Type oauth2
// @Flow password
// @TokenUrl http://swagger.io/api/oauth/token
// @Scopes write:pets="modify pets in your account" read:pets="read your pets"
//
// @GlobalParam userParam name=user required description="sadsadsad" in=body schema.$ref=package.hello
// @GlobalParam userParam2 name=user required description="sadsadsad" in=body schema.$ref=package.Data
//
// @GlobalResponse notFound desc="Entity not found." schema.$ref=package.hello
// @GlobalResponse notFound2 desc="Entity not found." schema.$ref=package.Data
//
// @Path /user/package.Data/{id}
// @Method GET
// @Param name=id required description="sadsadsad" in=path type=string
// @Param name=user required description="sadsadsad" in=body schema.$ref=package.Data
// @Produces json
// @Consumes json
// @Summary this is summary
// @Description this is description
// @Deprecated
// @Schemes http https
// @OperationId GetStart
// @Tags a b c
// @Security petstore_auth=write:pets,read:pets
// @Response 200 desc=123123 schema.$ref=package.NotFound
func main(){

}

##API

func main(){
  a := arlong.NewParser("~/go/src/path/to/package")
  b, err := a.JSON() //generate swagger 2.0 json format
}

##CLI

NAME:
   arlong - Genrate Swagger 2.0

USAGE:
   arlong [global options] command [command options] [arguments...]

VERSION:
   1.0.0

AUTHOR(S):

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --path, -p "."   Package path to generate
   --out, -o "."    Output Path
   --file, -f "swagger.json"  Output file name
   --help, -h     show help
   --version, -v    print the version

##Todo

  • More format
  • Generate Restful Go Client
  • Unit test
  • Compatible all swagger 2.0 spec
  • Document
  • Validate spec

##Contributing If you'd like to help out with the project. You can put up a Pull Request.

Documentation

Index

Constants

View Source
const (
	QUERY    = "query"
	FORMDATA = "formData"
	HEADER   = "header"
	PATH     = "path"
)
View Source
const (
	INT32    = "int32"
	INT64    = "int64"
	STRING   = "string"
	FLOAT    = "float"
	BOOL     = "bool"
	BYTE     = "byte"
	DATETIME = "datetime"
	DATE     = "date"
	PASSWORD = "password"
)
View Source
const (
	MIME_XML       = "application/xml"
	MIME_JSON      = "application/json"
	MIME_HTML      = "text/html"
	MIME_TEXT      = "text/plain"
	MIME_FORM      = "application/x-www-form-urlencoded"
	MIME_MULTIPART = "multipart/form-data"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Contact

type Contact struct {
	Name  string `json:"name,omitempty"`
	URL   string `json:"url,omitempty"`
	Email string `json:"email,omitempty"`
}

type Field

type Field struct {
	Type                 string  `json:"type,omitempty"`
	Description          string  `json:"description,omitempty"`
	Format               string  `json:"format,omitempty"`
	Items                *Items  `json:"items,omitempty"`
	Ref                  string  `json:"$ref,omitempty"`
	AdditionalProperties *Schema `json:"additionalProperties,omitempty"`
}
type Header struct {
	Description string `json:"description,omitempty"`
	Type        string `json:"type,omitempty"`
	Format      string `json:"format,omitempty"`
	Items       *Items `json:"items,omitempty"`
	Default     string `json:"default,omitempty"`
	Maximum     int    `json:"maximum,omitempty"`
	Minimum     int    `json:"minimum,omitempty"`
	MaxLength   int    `json:"maxLength,omitempty"`
	MinLength   int    `json:"minLength,omitempty"`
	MaxItems    int    `json:"maxItems,omitempty"`
	MinItems    int    `json:"minItems,omitempty"`
}

type Info

type Info struct {
	Title          string   `json:"title"`
	Description    string   `json:"description,omitempty"`
	TermsOfService string   `json:"termsOfService,omitempty"`
	Contact        *Contact `json:"contact,omitempty"`
	License        *License `json:"license,omitempty"`
	Version        string   `json:"version"`
}

type Items

type Items struct {
	Type      string      `json:"type,omitempty"`
	Format    string      `json:"format,omitempty"`
	Default   interface{} `json:"default,omitempty"`
	Maximum   int         `json:"maximum,omitempty"`
	Minimum   int         `json:"minimum,omitempty"`
	MaxLength int         `json:"maxLength,omitempty"`
	MinLength int         `json:"minLength,omitempty"`
	MaxItems  int         `json:"maxItems,omitempty"`
	MinItems  int         `json:"minItems,omitempty"`
}

type License

type License struct {
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`
}

type Operation

type Operation struct {
	Tags        []string              `json:"tags,omitempty"`
	Summary     string                `json:"summary,omitempty"`
	Description string                `json:"description,omitempty"`
	OperationId string                `json:"operationId,omitempty"`
	Consumes    []string              `json:"consumes,omitempty"`
	Produces    []string              `json:"produces,omitempty"`
	Parameters  []*Parameter          `json:"parameters,omitempty"`
	Responses   map[string]*Responses `json:"responses,omitempty"`
	Schemes     []string              `json:"schemes,omitempty"`
	Deprecated  bool                  `json:"deprecated,omitempty"`
	Security    []map[string][]string `json:"security,omitempty"`
}

type Parameter

type Parameter struct {
	Ref             string      `json:"$ref,omitempty"`
	Name            string      `json:"name,omitempty"`
	In              string      `json:"in,omitempty"`
	Description     string      `json:"description,omitempty"`
	Required        bool        `json:"required,omitempty"`
	Schema          *Schema     `json:"schema,omitempty"`
	Type            string      `json:"type,omitempty"`
	Format          string      `json:"format,omitempty"`
	AllowEmptyValue bool        `json:"allowEmptyValue,omitempty"`
	Items           *Items      `json:"items,omitempty"`
	Default         interface{} `json:"default,omitempty"`
	Maximum         int         `json:"maximum,omitempty"`
	Minimum         int         `json:"minimum,omitempty"`
	MaxLength       int         `json:"maxLength,omitempty"`
	MinLength       int         `json:"minLength,omitempty"`
	MaxItems        int         `json:"maxItems,omitempty"`
	MinItems        int         `json:"minItems,omitempty"`
}

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(basePkgPath string) *Parser

func (*Parser) JSON

func (p *Parser) JSON() ([]byte, error)

func (*Parser) Parse

func (p *Parser) Parse() error

type Path

type Path struct {
	Route      string      `json:"-"`
	Ref        string      `json:"$ref,omitempty"`
	GET        *Operation  `json:"get,omitempty"`
	PUT        *Operation  `json:"put,omitempty"`
	POST       *Operation  `json:"post,omitempty"`
	DELETE     *Operation  `json:"delete,omitempty"`
	OPTIONS    *Operation  `json:"options,omitempty"`
	HEAD       *Operation  `json:"head,omitempty"`
	PATCH      *Operation  `json:"patch,omitempty"`
	Parameters []Parameter `json:"parameters,omitempty"`
}

type Responses

type Responses struct {
	Ref         string             `json:"$ref,omitempty"`
	Description string             `json:"description"`
	Schema      *Schema            `json:"schema,omitempty"`
	Headers     map[string]*Header `json:"headers,omitempty"`
}

type Schema

type Schema struct {
	AllOf                []*Schema          `json:"allOf,omitempty"`
	Properties           map[string]*Schema `json:"properties,omitempty"`
	Required             []string           `json:"required,omitempty"`
	Type                 string             `json:"type,omitempty"`
	Format               string             `json:"format,omitempty"`
	Description          string             `json:"description,omitempty"`
	Items                *Schema            `json:"items,omitempty"`
	Ref                  string             `json:"$ref,omitempty"`
	AdditionalProperties *Schema            `json:"additionalProperties,omitempty"`
	// contains filtered or unexported fields
}

type SecurityDefinitions

type SecurityDefinitions struct {
	Type             string            `json:"type,omitempty"`
	Description      string            `json:"description,omitempty"`
	Name             string            `json:"name,omitempty"`
	In               string            `json:"in,omitempty"`
	Flow             string            `json:"flow,omitempty"`
	AuthorizationUrl string            `json:"authorizationUrl,omitempty"`
	TokenUrl         string            `json:"tokenUrl,omitempty"`
	Scopes           map[string]string `json:"scopes,omitempty"`
}

type Swagger

type Swagger struct {
	Swagger             string                          `json:"swagger,omitempty"`
	Info                Info                            `json:"info"`
	Host                string                          `json:"host,omitempty"`
	BasePath            string                          `json:"basePath,omitempty"`
	Schemes             []string                        `json:"schemes,omitempty"`
	Consumes            []string                        `json:"consumes,omitempty"`
	Produces            []string                        `json:"produces,omitempty"`
	Paths               map[string]*Path                `json:"paths"`
	Definitions         map[string]*Schema              `json:"definitions,omitempty"`
	Security            []map[string][]string           `json:"security,omitempty"`
	SecurityDefinitions map[string]*SecurityDefinitions `json:"securityDefinitions,omitempty"`
	Parameters          map[string]*Parameter           `json:"parameters,omitempty"`
	Responses           map[string]*Responses           `json:"responses,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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