Documentation
¶
Index ¶
- func ExtractAnnotation(line string) (string, bool)
- func MalformedModelName(line string) (string, bool)
- func MalformedResponseName(line string) (string, bool)
- func ModelOverride(comments *ast.CommentGroup) (string, bool)
- func ParametersOverride(comments *ast.CommentGroup) ([]string, bool)
- func ResponseOverride(comments *ast.CommentGroup) (string, bool)
- type ParsedPathContent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractAnnotation ¶
ExtractAnnotation returns the trailing identifier of a `swagger:<name>` marker found anywhere on line, or ("", false) if no marker is present.
Used by the scanner's annotation-classification index.
func MalformedModelName ¶ added in v0.35.0
MalformedModelName reports a `swagger:model` marker on line whose name argument is not a plain identifier.
Definition/response names are JSON labels, not Go-qualified identifiers, so a package-qualified name such as `utils.Error` is rejected by the strict rxModelOverride and the marker would otherwise be silently dropped.
Returns the offending raw argument and true; a bare marker or a well-formed name returns ("", false).
func MalformedResponseName ¶ added in v0.35.0
MalformedResponseName is the `swagger:response` counterpart of MalformedModelName.
func ModelOverride ¶
func ModelOverride(comments *ast.CommentGroup) (string, bool)
ModelOverride returns the name argument of a `swagger:model <name>` marker found anywhere in comments, or ("", true) when the marker is present without an argument (bare `swagger:model`).
Returns ("", false) when no marker is found.
func ParametersOverride ¶
func ParametersOverride(comments *ast.CommentGroup) ([]string, bool)
ParametersOverride returns every operation-id reference attached to a `swagger:parameters` marker.
One marker can carry several operation ids; multiple markers across comments accumulate.
func ResponseOverride ¶
func ResponseOverride(comments *ast.CommentGroup) (string, bool)
ResponseOverride returns the name argument of a `swagger:response <name>` marker, matching the bare-marker semantics of ModelOverride.
Types ¶
type ParsedPathContent ¶
type ParsedPathContent struct {
Method, Path, ID string
Tags []string
Remaining *ast.CommentGroup
// Pos is the position of the matched route/operation annotation line (the comment group's start).
//
// Used to anchor diagnostics such as the stripped-regex warning.
// Pos is the (coarse) source position of the matched route/operation annotation line — the comment's Slash.
//
// Used as:
// - anchor for diagnostics, such as the stripped-regex warning.
// - the cross-ref anchor for the /paths/{path}/{method} node. Invalid when no annotation matched.
Pos token.Pos
// UnparsedPos / UnparsedLine record a line recognisable as a path annotation — keyword, method and a path — that
// did not parse as one.
//
// Both are zero unless that happened.
//
// Nothing downstream can recover this: a `swagger:route` that fails its regex leaves no trace and reads as ordinary
// prose, so the route goes missing with no diagnostic anywhere.
// Capturing it here is what lets the caller say so — but only when the group produced no route at all, since a group
// may legitimately hold both a good annotation and prose that resembles one.
UnparsedPos token.Pos
UnparsedLine string
// StrippedParams names the path parameters whose inline regex constraint (gorilla/chi style, e.g. `{id:[0-9]+}`) was
// stripped to the bare `{id}` template form.
//
// OpenAPI 2.0 path templating supports only RFC 6570 URI Template Level-1 expansion (simple `{var}` substitution), so
// any `:regex` constraint is dropped and surfaced to the author by the route/operation builder.
StrippedParams []string
}
func ParseOperationPathAnnotation ¶
func ParseOperationPathAnnotation(lines []*ast.Comment) (cnt ParsedPathContent)
func ParseRoutePathAnnotation ¶
func ParseRoutePathAnnotation(lines []*ast.Comment) (cnt ParsedPathContent)
Directories
¶
| Path | Synopsis |
|---|---|
|
Package grammar is the annotation parser for codescan.
|
Package grammar is the annotation parser for codescan. |
|
Package routebody parses the body sub-language of swagger:route / swagger:operation `Parameters:` and `Responses:` raw blocks.
|
Package routebody parses the body sub-language of swagger:route / swagger:operation `Parameters:` and `Responses:` raw blocks. |
|
Package security is the sub-parser for the `Security:` block body that appears under `swagger:meta`, `swagger:route` and `swagger:operation`.
|
Package security is the sub-parser for the `Security:` block body that appears under `swagger:meta`, `swagger:route` and `swagger:operation`. |
|
Package yaml is a thin wrapper around go.yaml.in/yaml/v3 for consuming the RawYAML bodies that internal/parsers/grammar/ isolates between `---` fences, plus the typed-extensions service the grammar lexer calls for `extensions:` raw blocks.
|
Package yaml is a thin wrapper around go.yaml.in/yaml/v3 for consuming the RawYAML bodies that internal/parsers/grammar/ isolates between `---` fences, plus the typed-extensions service the grammar lexer calls for `extensions:` raw blocks. |