parsers

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAnnotation

func ExtractAnnotation(line string) (string, bool)

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

func MalformedModelName(line string) (string, bool)

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

func MalformedResponseName(line string) (string, bool)

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

	// 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.

Jump to

Keyboard shortcuts

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