commonparams

package
v1.15.1 Latest Latest
Warning

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

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

Documentation

Overview

Package commonparams moves path-level parameters to individual operations.

Overview

OpenAPI allows defining "common parameters" at the path level that apply to all operations under that path. This package moves those parameters into each operation, which improves diff accuracy by ensuring parameter comparisons happen at the operation level.

See: https://swagger.io/docs/specification/describing-parameters/

Usage

Move common parameters in a spec:

commonparams.Move(spec)

Or use via the load package option:

specInfo, err := load.NewSpecInfo(loader, source, load.WithFlattenParams())

Behavior

  • Parameters defined at path level are copied to each operation under that path
  • If an operation already has a parameter with the same name and location, the operation-level parameter takes precedence (no duplication)
  • After processing, path-level parameters are removed

Example

Before:

/users/{id}:
  parameters:
    - name: id
      in: path
  get:
    summary: Get user

After:

/users/{id}:
  get:
    summary: Get user
    parameters:
      - name: id
        in: path

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Move

func Move(spec *openapi3.T)

Move moves common parameters to the operations under the path

Types

This section is empty.

Jump to

Keyboard shortcuts

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