codegen

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize() error

func RefTypeMapping

func RefTypeMapping() map[string]string

Types

type CodegenService

type CodegenService struct {
	Swagger *openapi3.T
	Config  Configuration
}

func NewCodegenService

func NewCodegenService(swagger *openapi3.T, config Configuration) *CodegenService

func (CodegenService) Generate

func (s CodegenService) Generate() (string, error)

type Configuration

type Configuration struct {
	PackageName      string        `yaml:"package"`
	WorkingDirectory string        `yaml:"directory,omitempty"`
	OutputOptions    OutputOptions `yaml:"out-options,omitempty"`
	UserTemplates    UserTemplates `yaml:"user-templates,omitempty"`
}

func (Configuration) UpdateDefaultValues

func (c Configuration) UpdateDefaultValues() Configuration

func (Configuration) Validate

func (c Configuration) Validate() error

type ControllerData

type ControllerData struct {
	ClassName             string
	ServiceName           string
	Definitions           []Definition
	ControllerParentClass string
	ServiceParentClass    string
}

type Definition

type Definition struct {
	MethodName      string
	HttpMethod      string
	Path            string
	Parameters      []ParameterDefinition
	BodyParameters  RequestBodyDefinition
	ControllerName  string
	IsResfulIndex   bool
	IsResfulShow    bool
	IsResfulCreate  bool
	IsResfulUpdate  bool
	IsResfulDestroy bool
}

type GeneratedDir

type GeneratedDir struct {
	ControllerDir string
	ServiceDir    string
	RoutesDir     string
	PackageDir    string
}

type OperationDefinition

type OperationDefinition struct {
	Tag          string
	OperationId  string
	Method       string
	Path         string
	HeaderParams []ParameterDefinition
	PathParams   []ParameterDefinition
	QueryParams  []ParameterDefinition
	BodyParams   RequestBodyDefinition
}

func OperationDefinitions

func OperationDefinitions(swagger *openapi3.T) ([]OperationDefinition, error)

type OutputOptions

type OutputOptions struct {
	ControllerPrefix      string `yaml:"controller-prefix,omitempty"`
	ServicePrefix         string `yaml:"service-prefix,omitempty"`
	ControllerParentClass string `yaml:"controller-parent-class,omitempty"`
	ServiceParentClass    string `yaml:"service-parent-class,omitempty"`
	RegenerateService     bool   `yaml:"regenerate-service"`
	ControllerDirectory   string `yaml:"controller-directory,omitempty"`
	ServiceDirectory      string `yaml:"service-directory,omitempty"`
	RoutesDirectory       string `yaml:"routes-directory,omitempty"`
}

type ParameterDefinition

type ParameterDefinition struct {
	ParamName string
	In        string
	Required  bool
	Spec      *openapi3.Parameter
	Schema    Schema
}

type ParameterDefinitions

type ParameterDefinitions []ParameterDefinition

type Property

type Property struct {
	Name     string
	Required bool
	Schema   Schema
}

type RequestBodyDefinition

type RequestBodyDefinition struct {
	Schema Schema
	Spec   *openapi3.Schema
}

func DescribeRequestBody

func DescribeRequestBody(requestBody *openapi3.RequestBodyRef) (RequestBodyDefinition, error)

type Schema

type Schema struct {
	RefType    string
	EnumValues []string
	Properties []Property
	OAPISchema *openapi3.Schema
	ArrayItems *Schema
}

func DescribeSchemaRef

func DescribeSchemaRef(schemaRef *openapi3.Schema) (Schema, error)

type UserTemplates

type UserTemplates struct {
	Controller string `yaml:"controller,omitempty"`
	Service    string `yaml:"service,omitempty"`
	Routes     string `yaml:"routes,omitempty"`
}

Jump to

Keyboard shortcuts

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