lanai

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FullPath = iota
	PathFromApi
	VersionFromPath
	PathAfterVersion
)
View Source
const (
	PathRegex = ".+(\\/api\\/(v\\d+)\\/(.+))"
)

Variables

View Source
var FuncMap = template.FuncMap{
	"importsUsedByPath":   ImportsUsedByPath,
	"containsSingularRef": containsSingularRef,
	"isEmpty":             isEmpty,
	"schemaToText":        SchemaToText,
	"propertyToGoType":    PropertyToGoType,
	"shouldHavePointer":   ShouldHavePointer,
	"structTags":          structTags,
	"registerRegex":       registerRegex,
	"regex":               NewRegex,
	"versionList":         versionList,
	"mappingName":         mappingName,
	"mappingPath":         mappingPath,
	"defaultNameFromPath": defaultNameFromPath,
	"components":          NewComponents,
	"requestBody":         NewRequestBody,
	"operation":           NewOperation,
	"property":            NewProperty,
	"schema":              NewSchema,
}

Functions

func AddPredefinedRegexes

func AddPredefinedRegexes(initialRegexes map[string]string)

func ImportsUsedByPath

func ImportsUsedByPath(pathItem openapi3.PathItem, repositoryPath string) []string

func Load

func Load()

func PropertyToGoType

func PropertyToGoType(p Property) (string, error)

func SchemaToText

func SchemaToText(element interface{}, defaultObjectName string, currentPkg string) (string, error)

func ShouldHavePointer

func ShouldHavePointer(p Property) bool

Types

type Components

type Components struct {
	openapi.Components
}

func NewComponents

func NewComponents(data openapi3.Components) Components

func (Components) Imports

func (c Components) Imports() (result []string)

type Operation

type Operation struct {
	Name string
	Data *openapi3.Operation
}

func NewOperation

func NewOperation(data *openapi3.Operation, defaultName string) Operation

func (Operation) AllResponseContent

func (o Operation) AllResponseContent() (result []*openapi3.MediaType)

func (Operation) RequestRefsUsed

func (o Operation) RequestRefsUsed() (result []string)

func (Operation) RequestStruct

func (o Operation) RequestStruct(structRegistry map[string]string) *_go.Struct

func (Operation) ResponseRefsUsed

func (o Operation) ResponseRefsUsed() (result []string)

func (Operation) ResponseStruct

func (o Operation) ResponseStruct(structRegistry map[string]string) *_go.Struct

func (Operation) StructForMessage

func (o Operation) StructForMessage(messageType string, structRegistry map[string]string) (*_go.Struct, error)

type Parameters

type Parameters struct {
	openapi.Parameters
}

func (Parameters) ExternalImports

func (r Parameters) ExternalImports() []string

type Property

type Property struct {
	PropertyName string
	CurrentPkg   string
	TypePrefix   string
	OmitJSON     bool
	RequiredList []string
	PropertyData interface{}
}

func NewProperty

func NewProperty(data interface{}, name string, requiredList []string, currentPkg string, typePrefix ...string) Property

func (Property) IsOptional

func (p Property) IsOptional() bool

func (Property) SetOmitJSON

func (p Property) SetOmitJSON(val bool) Property

type RefChecker

type RefChecker interface {
	CountFields() int
	ContainsRef() bool
}

type Regex

type Regex struct {
	Value string
	Name  string
}

func NewRegex

func NewRegex(value openapi3.Schema) (*Regex, error)

type RequestBody

type RequestBody struct {
	openapi.RequestBody
}

func NewRequestBody

func NewRequestBody(body openapi3.RequestBodyRef) RequestBody

func (RequestBody) ExternalImports

func (r RequestBody) ExternalImports() (result []string)

type Response

type Response struct {
	openapi.Response
}

func (Response) ExternalImports

func (r Response) ExternalImports() (result []string)

type Responses

type Responses struct {
	openapi.Responses
}

func NewResponses

func NewResponses(src *openapi3.Responses) *Responses

func (Responses) ExternalImports

func (r Responses) ExternalImports() (result []string)

type Schema

type Schema struct {
	Name string
	Data *openapi3.SchemaRef
}

func NewSchema

func NewSchema(name string, data *openapi3.SchemaRef) Schema

func (Schema) AllProperties

func (s Schema) AllProperties() (result openapi3.Schemas)

func (Schema) AllSchemas

func (s Schema) AllSchemas() openapi3.SchemaRefs

func (Schema) HasAdditionalProperties

func (s Schema) HasAdditionalProperties() bool

func (Schema) StructProperties

func (s Schema) StructProperties() (result openapi3.SchemaRefs)

func (Schema) Type

func (s Schema) Type() string

type SchemaRef

type SchemaRef openapi.SchemaRef

func (SchemaRef) AllSchemas

func (s SchemaRef) AllSchemas() openapi3.SchemaRefs

func (SchemaRef) HasAdditionalProperties

func (s SchemaRef) HasAdditionalProperties() bool

func (SchemaRef) StructProperties

func (s SchemaRef) StructProperties() (result openapi3.SchemaRefs)

StructProperties will return the schemas to be turned into properties for the struct Includes: The base schema if: - it is not AllOf - or it is a ref - or has additionalProperties Individual schemas part of an AllOf that match the above, if the schema isn't already a Ref

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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