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
()
| 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 |
| 1682 | func (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. |