Documentation
¶
Overview ¶
templ: version: v0.3.924
Index ¶
- func ConstructIdent(c Case, parts ...string) string
- func FindNonInlinableSchemas(format Case, o openapi.OpenAPI) iter.Seq2[string, openapi.Schema]
- func Page(options options.Options, gen Generation, httpMode bool) templ.Component
- func ResolveOperationName(format Case, path, method string, o openapi.Operation) string
- type Case
- type Config
- type Generation
- type Generator
- type Golang
- type InvalidLanguageError
- type Operation
- type Param
- type Schema
- type TypeScript
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructIdent ¶
ConstructIdent combines parts with the given Case and returns a new formatted ident.
Examples:
ConstructIdent(SnakeCase, "get", "user", "response") // "get_user_response" ConstructIdent(CamelCase, "get", "user", "response") // "getUserResponse" ConstructIdent(PascalCase, "get", "user", "response") // "GetUserResponse"
func FindNonInlinableSchemas ¶ added in v0.8.0
FindNonInlinableSchemas find all schemas that cannot be inlined and returns an iterator over those schemas and the recommended schema name based on its origin.
When a schema cannot be inlined, a top-level declaration should be generated.
The schema names will be the format case.
func ResolveOperationName ¶ added in v0.8.0
ResolveOperationName returns either a formatted operation summary or a combination of method+path.
Examples:
ResolveOperationName(PascalCase, "/users", "get", operation) // "GetUsers" operation.Summary = "retrieve user entries" ResolveOperationName(PascalCase, "/users", "get", operation) // "RetrieveUserEntries"
Types ¶
type Config ¶ added in v0.8.0
type Config struct {
// Package name for languages like Go, where a top level name is required.
// PackageName is derived from OpenAPI.Info.Title, and defaults to "api" when a title is not found.
PackageName string
// List of top-level schemas, including all schemas from Components.Schemas, and
// operation request bodies and responses that cannot be inlined in code.
Schemas []Schema
Operations []Operation
// Language specific generator for access to utility functions.
Generator Generator
}
Config represent all necessary data for generating API client code.
type Generation ¶
Generation represents the generated code for a specific programming language
type Generator ¶ added in v0.8.0
type Generator interface {
// SchemaType returns a type declaration for the specific schema.
// It is expected to be recursive for nested schemas, and will automatically handle indentation.
// By default, the indentation starts at 0 (top-level).
SchemaType(schema openapi.Schema) string
// FunctionNameFormat returns the formatting for function names.
FunctionNameFormat() Case
// TypeNameFormat returns the formatting for type declaration names.
TypeNameFormat() Case
// VariableNameFormat returns the formatting for variable names.
VariableNameFormat() Case
// IdentEscape escapes any invalid characters in an identifier name.
// An identifier may be a function, variable, class, or type name.
IdentEscape(ident string) string
}
Generator represents a single programming language and it's conventions, and syntax rules.
type Golang ¶
type Golang struct{}
func (*Golang) FunctionNameFormat ¶ added in v0.8.0
func (*Golang) IdentEscape ¶ added in v0.8.0
func (*Golang) SchemaType ¶ added in v0.8.0
func (*Golang) TypeNameFormat ¶ added in v0.8.0
func (*Golang) VariableNameFormat ¶ added in v0.8.0
type InvalidLanguageError ¶
type InvalidLanguageError struct {
// contains filtered or unexported fields
}
func (*InvalidLanguageError) Error ¶
func (err *InvalidLanguageError) Error() string
type Operation ¶ added in v0.8.0
type Operation struct {
URL string
Method string
Name string
Description string
// List of function parameters
Params []Param
// The returned schema type of the function.
// Empty string when there is no expected response body.
ReturnType string
HasRequestBody bool
IsRequestBodyRequired bool
}
func CollectOperations ¶ added in v0.8.0
func (*Operation) CookieParams ¶ added in v0.8.0
func (*Operation) HasHeaderOrCookieParams ¶ added in v0.8.0
func (*Operation) HeaderParams ¶ added in v0.8.0
func (*Operation) PathParams ¶ added in v0.8.0
func (*Operation) QueryParams ¶ added in v0.8.0
type Param ¶ added in v0.8.0
type Param struct {
// Name of the function parameter
Name string
// Name of the header, query, path value, or cookie.
// May be empty for special parameters, such as request body.
BaseName string
Type string
HasMore bool
Required bool
// contains filtered or unexported fields
}
Param represents a single function parameter
type TypeScript ¶
type TypeScript struct{}
func NewTypeScript ¶
func NewTypeScript() *TypeScript
func (*TypeScript) FunctionNameFormat ¶ added in v0.8.0
func (ts *TypeScript) FunctionNameFormat() Case
func (*TypeScript) IdentEscape ¶ added in v0.8.0
func (ts *TypeScript) IdentEscape(ident string) string
func (*TypeScript) SchemaType ¶ added in v0.8.0
func (ts *TypeScript) SchemaType(schema openapi.Schema) string
func (*TypeScript) TypeNameFormat ¶ added in v0.8.0
func (ts *TypeScript) TypeNameFormat() Case
func (*TypeScript) VariableNameFormat ¶ added in v0.8.0
func (ts *TypeScript) VariableNameFormat() Case