security

package
v0.34.1 Latest Latest
Warning

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

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

Documentation

Overview

Package security is a thin sub-parser for the `Security:` block body that appears under both `swagger:meta` and `swagger:route`. The body shape is one requirement per line:

name: scope1, scope2

where the scope list may be empty (a bare `name:` is permitted) and scopes are whitespace-trimmed.

Sibling of `internal/parsers/yaml/`: imported by `internal/parsers/grammar/` from the lexer-time dispatch in emitRawBlock (the same seam yaml.TypedExtensions plugs into for the `extensions:` keyword). Builders read the typed result via `grammar.Block.SecurityRequirements()` rather than re-parsing the raw body — same shape extensions already follows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Requirement

type Requirement = map[string][]string

Requirement is one Security: line's contribution to the spec: a single-entry map from name → scope list. Multiple Requirements build up across lines.

func Parse

func Parse(body string) []Requirement

Parse splits body on newlines and parses each non-blank line as a `name: scope1, scope2` security requirement. Empty body returns nil.

V1 quirk preserved: a scope that contains whitespace truncates at its first word — fixtures today only use single-word scopes, so the truncation is invisible, but the regression risk is real enough to keep the behaviour locked.

Jump to

Keyboard shortcuts

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