Documentation
¶
Overview ¶
Package naming turns spec names into Go names and settles clashes between them.
Index ¶
- func ImportName(path string) string
- func Package(dir string) string
- type Assignment
- type Namer
- func (n *Namer) ArrayItem(parent string) string
- func (n *Namer) ClientOption(client string) string
- func (n *Namer) ClientRequestOptions(op string) string
- func (n *Namer) ClientResponse(op string) string
- func (n *Namer) EnumConst(typ, value string) string
- func (n *Namer) EnumValues(typ string) string
- func (n *Namer) Exported(parts ...string) string
- func (n *Namer) InlineProperty(parent, prop string) string
- func (n *Namer) Interface(name string) string
- func (n *Namer) MapValue(parent string) string
- func (n *Namer) MediaTag(contentType string) string
- func (n *Namer) Params(op, in string) string
- func (n *Namer) RequestBody(op, contentType string, multiple bool) string
- func (n *Namer) Response(op, status, contentType string, multiple bool) string
- func (n *Namer) ResponseConstructor(op, status string, multiple bool) string
- func (n *Namer) ResponseData(op string) string
- func (n *Namer) ResponseHeaders(op, status string) string
- func (n *Namer) ResponseItem(op string) string
- func (n *Namer) ServiceRequestOptions(op string) string
- func (n *Namer) Snake(name string) string
- func (n *Namer) Status(status string) string
- func (n *Namer) ToolInput(op string) string
- func (n *Namer) Unexported(parts ...string) string
- func (n *Namer) UnionVariant(parent, title, discValue string, index int) string
- type Rank
- type Rename
- type Request
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImportName ¶
ImportName returns the name the package at an import path has by the usual layout of module paths: a major version suffix (v2) and a go- prefix are not part of the name, nor is anything after a dot (yaml.v3). It is empty when what is left is no Go name.
Types ¶
type Assignment ¶
type Namer ¶
type Namer struct {
// contains filtered or unexported fields
}
Namer builds Go names. Suffix methods keep their first argument as is and convert the rest.
func (*Namer) ClientOption ¶
ClientOption names the option type of a client: ClientOption.
func (*Namer) ClientRequestOptions ¶
ClientRequestOptions names what the client method of an operation sends.
func (*Namer) ClientResponse ¶
ClientResponse names what the WithResponse client method of an operation returns.
func (*Namer) EnumValues ¶
EnumValues names the func that returns every value of an enum: StatusValues.
func (*Namer) InlineProperty ¶
InlineProperty names the type of an inline schema under a property: OrderClientAddress.
func (*Namer) Interface ¶
Interface names the interface of a service or a client: ServiceInterface, ClientInterface.
func (*Namer) MapValue ¶
MapValue names the type of an inline additionalProperties schema: LabelsValue.
func (*Namer) MediaTag ¶
MediaTag shortens a media type: application/problem+json gives ProblemJSON.
func (*Namer) Params ¶
Params names the struct for one parameter location: GetPetPathParams, GetPetQuery.
func (*Namer) RequestBody ¶
RequestBody adds the media type only when the operation has more than one body.
func (*Namer) Response ¶
Response names an inline response: GetPetResponse200, GetPetResponse4XX, GetPetResponseDefault. The media type is added only when the response has more than one: GetPetJSONResponse200.
func (*Namer) ResponseConstructor ¶
ResponseConstructor names the function that makes the response data of an operation from the body of one status: NewGetPetResponseData, or NewGetPetResponseData404 among several.
func (*Namer) ResponseData ¶
ResponseData names what the service method of an operation returns.
func (*Namer) ResponseHeaders ¶
ResponseHeaders names the typed headers of a response: GetPetResponse200Headers.
func (*Namer) ResponseItem ¶
ResponseItem names the inline schema of one frame of a streamed response: GetEventsResponseItem.
func (*Namer) ServiceRequestOptions ¶
ServiceRequestOptions names what the service method of an operation receives.
func (*Namer) Snake ¶
Snake writes a Go name in snake case: GetPetByID gives get_pet_by_id, HTTP2Stats http2_stats.
func (*Namer) Unexported ¶
Unexported joins parts into one lowerCamel identifier. A keyword or predeclared name gets "Val".
type Rename ¶
type Rename struct {
ID string
From string
To string
Holder string
IsDerived bool
Rank Rank
Origin diag.Origin
}
Rename records a lost name. From is the name that was taken: Want, or Want plus one of its Derived suffixes. Holder is the ID that has From, empty when From is reserved; IsDerived says Holder built it from its own name.
func (Rename) Diagnostic ¶
func (r Rename) Diagnostic() diag.Diagnostic
Diagnostic reports the rename; a lost x-go-name is a warning, anything else is info.
type Request ¶
type Request struct {
ID string
Want string
// Fallback is tried before numbering: Fallback2, Fallback3, or Want2 without a Fallback.
Fallback string
// Derived are the suffixes of the names the generator builds from the name, such as methods:
// the request holds its name plus each of them too, so a name is free only when all are.
Derived []string
Rank Rank
Order int
Origin diag.Origin
}
Request asks for one name. ID is unique within a Resolve call, usually a JSON pointer.