Help us shape the future of Go! Take the 2026 Go Developer Survey

swagger2

package
v1.150.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package swagger2 converts a Swagger 2.0 document to the OpenAPI 3 the API gateway reads (#2005). Many generators (swaggo/swag, the usual one for Go APIs) still emit 2.0, and an operator pasting one should not have to know that before saving it. A catalog spec saved or refreshed as 2.0, and the platform's own admin API document, go through the one conversion here.

Index

Constants

View Source
const ConvertedFrom = "swagger 2.0"

ConvertedFrom names the format a spec's content was converted from when it was supplied as Swagger 2.0.

Variables

View Source
var ErrNotSwagger = errors.New("swagger2: not a Swagger 2.0 document")

ErrNotSwagger is returned by Convert for a document that does not declare `swagger: "2.0"`.

Functions

func Convert

func Convert(raw string) (string, error)

Convert converts a Swagger 2.0 document, JSON or YAML, to OpenAPI 3 JSON.

func Is

func Is(raw string) bool

Is reports whether raw, JSON or YAML, declares `swagger: "2.0"`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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