stdopenapi

package
v0.0.257 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 6 Imported by: ? 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 stdopenapi works with OpenAPI documents.

Index

Constants

View Source
const DownConvertVersion = "3.0.3"

DownConvertVersion is the OpenAPI version that DownConvert produces.

Variables

This section is empty.

Functions

func DownConvert

func DownConvert(spec []byte) ([]byte, error)

DownConvert converts an OpenAPI 3.1 document, in YAML or JSON, to an OpenAPI 3.0.3 document in YAML, for clients that do not support 3.1. It rewrites the 3.1 constructs that have a 3.0 equivalent:

  • a type list with "null", such as [string, "null"], becomes the type and nullable: true;
  • a schema's examples become its first example;
  • const becomes an enum of one value;
  • a numeric exclusiveMinimum or exclusiveMaximum becomes minimum or maximum, with the boolean exclusiveMinimum or exclusiveMaximum;
  • a $ref with sibling keywords becomes an allOf of the $ref, next to the siblings, since OpenAPI 3.0 ignores the siblings of a $ref;
  • a boolean unevaluatedProperties is dropped: OpenAPI 3.0 cannot close an object over the properties of its allOf, anyOf, or oneOf, so the object accepts other properties too. protoc-gen-connect-openapi writes unevaluatedProperties: false for messages with a oneof.

It fails on the 3.1 constructs that OpenAPI 3.0 cannot express, such as webhooks, prefixItems, or a type list of several types, and reports where each one is, instead of dropping them. It keeps the order of keys, and writes mappings and sequences in block style.

It follows the rules of Apiture's openapi-down-convert (https://github.com/apiture/openapi-down-convert) where both convert a construct, but fails where that tool drops one. For more parity, it could also drop the constructs that only document: the summary and description next to a $ref, info.summary, info.license.identifier, $id and $schema, and $comment, which that tool renames to x-comment. And it could convert contentEncoding: base64 to format: byte, and contentMediaType to format: binary.

Types

This section is empty.

Directories

Path Synopsis
cmd
stdopenapi-downconvert command
Command stdopenapi-downconvert converts an OpenAPI 3.1 document to OpenAPI 3.0.3, for clients that do not support 3.1.
Command stdopenapi-downconvert converts an OpenAPI 3.1 document to OpenAPI 3.0.3, for clients that do not support 3.1.

Jump to

Keyboard shortcuts

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