openapi

package
v0.0.0-...-3297e96 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateGoSDK

func GenerateGoSDK(schemaFile string, outDir string) error

GenerateGoSDK generates a Go api sdk from an openapi schema file.

Types

type Info

type Info struct {
	Description string `json:"description" yaml:"description"`
	Title       string `json:"title" yaml:"title"`
	Version     string `json:"version" yaml:"version"`
}

type OpenAPISchema

type OpenAPISchema struct {
	BasePath            string                        `json:"basePath" yaml:"basePath"`
	Consumes            []string                      `json:"consumes" yaml:"consumes"`
	Definitions         map[string]Property           `json:"definitions" yaml:"definitions"`
	Host                string                        `json:"host" yaml:"host"`
	Info                Info                          `json:"info" yaml:"info"`
	Paths               map[string]map[string]Path    `json:"paths" yaml:"paths"`
	Produces            []string                      `json:"produces" yaml:"produces"`
	Responses           map[string]Property           `json:"responses" yaml:"responses"`
	Schemes             []string                      `json:"schemes" yaml:"schemes"`
	SecurityDefinitions map[string]SecurityDefinition `json:"securityDefinitions" yaml:"securityDefinitions"`
	Swagger             string                        `json:"swagger" yaml:"swagger"`
	RefMap              map[string]string
	RefPropertyMap      map[string]Property
	ApiPathsMap         map[string]map[string]map[string]Path
}

func LoadOpenApiSchema

func LoadOpenApiSchema(filePath string) (*OpenAPISchema, error)

LoadOpenApiSchema loads open api schema from api schema file.

type Path

type Path struct {
	Description string                `json:"description" yaml:"description"`
	OperationID string                `json:"operationId" yaml:"operationId"`
	Parameters  []PathParameter       `json:"parameters" yaml:"parameters"`
	Responses   map[string]Property   `json:"responses" yaml:"responses"`
	Summary     string                `json:"summary" yaml:"summary"`
	Tags        []string              `json:"tags" yaml:"tags"`
	Security    []map[string][]string `json:"security" yaml:"security"`
	Schemes     []string              `json:"schemes" yaml:"schemes"`
	Consumes    []string              `json:"consumes" yaml:"consumes"`
	Produces    []string              `json:"produces" yaml:"produces"`
}

type PathParameter

type PathParameter struct {
	Description string   `json:"description" yaml:"description"`
	In          string   `json:"in" yaml:"in"`
	Name        string   `json:"name" yaml:"name"`
	Required    bool     `json:"required" yaml:"required"`
	Schema      Property `json:"schema" yaml:"schema"`
}

type Property

type Property struct {
	Description          string              `json:"description" yaml:"description"`
	Properties           map[string]Property `json:"properties" yaml:"properties"`
	Required             []string            `json:"required" yaml:"required"`
	Type                 string              `json:"type" yaml:"type"`
	XGoPackage           string              `json:"x-go-package" yaml:"x-go-package"`
	Ref                  string              `json:"$ref" yaml:"$ref"`
	Format               string              `json:"format" yaml:"format"`
	XGoName              string              `json:"x-go-name" yaml:"x-go-name"`
	AdditionalProperties *Property           `json:"additionalProperties" yaml:"additionalProperties"`
	Items                *Property           `json:"items" yaml:"items"`
	XML                  struct {
		Name    string `json:"name" yaml:"name"`
		Wrapped bool   `json:"wrapped" yaml:"wrapped"`
	} `json:"xml"`
	Default struct {
		Description string `json:"description" yaml:"description"`
	} `json:"default"`
	Schema *Property `json:"schema" yaml:"schema"`
}

func (Property) IsRequired

func (p Property) IsRequired(str string) bool

type SecurityDefinition

type SecurityDefinition struct {
	Type             string `json:"type" yaml:"type"`
	Name             string `json:"name" yaml:"name"`
	In               string `json:"in" yaml:"in"`
	AuthorizationURL string `json:"authorizationUrl" yaml:"authorizationUrl"`
	Flow             string `json:"flow" yaml:"flow"`
	Scopes           struct {
		ReadPets  string `json:"read:pets" yaml:"read:pets"`
		WritePets string `json:"write:pets" yaml:"write:pets"`
	} `json:"scopes"`
}

type TypeName

type TypeName string

func (TypeName) IsBuiltIn

func (t TypeName) IsBuiltIn() bool

func (TypeName) IsNullable

func (t TypeName) IsNullable() bool

func (TypeName) String

func (t TypeName) String() string

Jump to

Keyboard shortcuts

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