Repository navigation
Breaking changes
Regenerating code with this release may require changes in code that uses it.
- Convenient errors for decode errors (#1825, fixes #1514). When convenient errors are enabled,
*ogenerrors.DecodeParamsErrorand*ogenerrors.DecodeRequestErrorare passed toHandler.NewErrorand encoded as the error response, the same way security errors are. Previously they always went toServerConfig.ErrorHandler. Implementations that return a fixed 500 for every error should check for these types to keep a 400 response:Webhooks and servers without convenient errors are unchanged.func (h *handler) NewError(ctx context.Context, err error) *api.ErrorStatusCode { var ( paramsErr *ogenerrors.DecodeParamsError requestErr *ogenerrors.DecodeRequestError ) if errors.As(err, ¶msErr) || errors.As(err, &requestErr) { return &api.ErrorStatusCode{StatusCode: http.StatusBadRequest /* ... */} } // ... }
- Length of JSON byte strings (#1816, fixes #1504 and #1570).
pattern,minLengthandmaxLengthofformat: byteandformat: base64strings in JSON are checked against the base64 string, as the spec says, not against decoded bytes. Specs that usedmaxLengthas a limit on decoded bytes become stricter. Parameters and form fields are validated as before. - YAML 1.2 raw values (#1820, fixes #1317).
enum,default,example,constand extension values follow YAML 1.2, like the rest of the spec: onlytrueandfalseare booleans, soenum: [ON, OFF]is a string enum now. A spec that relied on YAML 1.1 booleans, likedefault: yesfor abooleanschema, fails with a type mismatch. MarshalJSONof unset optional values (#1828, fixes #660).json.Marshalof an unsetOpt*orOptNil*value returnsnullinstead of failing withunexpected end of JSON input, andUnmarshalJSONofOpt*decodesnullas unset. Only theencoding/jsonmethods change; the generated client and server still rejectnullfor non-nullable fields.
Features
- Numeric
exclusiveMinimumandexclusiveMaximumfrom OpenAPI 3.1 (JSON Schema 2020-12) are supported (#1821, fixes #1366). Both numeric and boolean forms are accepted regardless of the spec version.
Fixes
- Complex
uniqueItems(#1833):EqualandHashcode is generated recursively, so maps of structs or slices, optional arrays, arrays of aliases, sums, maps, arrays and untyped items are supported. The code is written tooas_equal_gen.goinstead of a pair of files per type.--cleandoesn't remove the oldapi_validators_unique_gen.go, delete it manually. - Inlined schemas no longer conflict with component schemas of the same name, and enum constants no longer conflict with type names (#1832). With #1833, the Mist spec from #1507 generates and compiles.
uniqueItemsis ignored for non-array types (#1819, fixes #1507).- Sum selector type
<Sum>Typeno longer conflicts with a schema of the same name (#1826, fixes #990). nullvariants of sum types are supported in parameters (#1827), e.g.anyOf: [integer, string, null]from FastAPI specs.- Optional nullable recursive fields reference a defined type (#1822, fixes #1488), and optional types of recursive structs no longer conflict (#1830).
- Sums of several object sums are not discriminated by JSON type (#1818, fixes #1480).
- Properties with
formatbut withouttypecompile (#1817, fixes #1471). - Forms with
additionalProperties,patternPropertiesoroneOf/anyOfinline fields no longer panic (#1815).
Dependencies
github.com/dlclark/regexp2/v22.13.3.
Full Changelog: v1.26.0...v1.27.0