MCPcopy
hub / github.com/danielgtaylor/huma / Downgrade

Method Downgrade

openapi.go:1682–1693  ·  view source on GitHub ↗

Downgrade converts this OpenAPI 3.1 spec to OpenAPI 3.0.3, returning the JSON []byte representation of the downgraded spec. This mostly exists to provide an alternative spec for tools which are not yet 3.1 compatible. It reverses the changes documented at: https://www.openapis.org/blog/2021/02/16/m

()

Source from the content-addressed store, hash-verified

1680// It reverses the changes documented at:
1681// https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
1682func (o OpenAPI) Downgrade() ([]byte, error) {
1683 b, err := o.MarshalJSON()
1684 if err == nil {
1685 var v any
1686 json.Unmarshal(b, &v)
1687
1688 downgradeSpec(v)
1689
1690 b, err = json.Marshal(v)
1691 }
1692 return b, err
1693}
1694
1695// DowngradeYAML converts this OpenAPI 3.1 spec to OpenAPI 3.0.3, returning the
1696// YAML []byte representation of the downgraded spec.

Callers 3

DowngradeYAMLMethod · 0.95
TestDowngradeFunction · 0.95
NewAPIFunction · 0.80

Calls 4

MarshalJSONMethod · 0.95
downgradeSpecFunction · 0.85
UnmarshalMethod · 0.65
MarshalMethod · 0.65

Tested by 1

TestDowngradeFunction · 0.76