swagger2

package
v1.171.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"`. A JSON document is read as JSON: a YAML parser reading a large JSON document allocates many times its size (#2721).

Types

This section is empty.

Jump to

Keyboard shortcuts

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