ParkWithEase / parkeasy

ParkEasy monorepo
0 stars 1 forks source link

fix(backend/deps): update module github.com/danielgtaylor/huma/v2 to v2.25.0 #270

Closed renovate[bot] closed 1 week ago

renovate[bot] commented 1 week ago

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
github.com/danielgtaylor/huma/v2 v2.22.1 -> v2.25.0 age adoption passing confidence

Release Notes

danielgtaylor/huma (github.com/danielgtaylor/huma/v2) ### [`v2.25.0`](https://redirect.github.com/danielgtaylor/huma/releases/tag/v2.25.0) [Compare Source](https://redirect.github.com/danielgtaylor/huma/compare/v2.24.0...v2.25.0) #### Overview ##### Case-insensitive JSON Since the standard library Go unmarshaler supports case-insensitive field matches, Huma has been updated to support this during validation as well to better support integration with legacy systems & clients. This behavior can be disabled by explicitly setting `huma.ValidateStrictCasing = true` (the default matches the standard library behavior). For example, given: ```go huma.Put(api, "/demo", func(ctx context.Context, input *struct{ Body struct { Value string `json:"value"` } }) (*struct{}, error) { fmt.Println("Value is", input.Body.Value) return nil, nil }) ``` If a client were to send `{"Value": "test"}` instead of `{"value": "test"}` it will now pass validation and work. This also works for the built-in CBOR format as well. ##### Support Scalar Pointers with Defaults Defaults have become more useful by enabling the use of pointers for basic types to have default values attached. For example, given this input to an operation: ```go type MyInput struct { Body struct { Enabled *bool `json:"enabled,omitempty" default:"true"` } } ``` It's now possible to explicitly send `false` without the value being overridden by the default. The behavior seen by the handler code is this: | Client sends | Handler sees | | -------------|-------------- | | `true` | `true` | | `false` | `false` | | `null` / `undefined` | `true` | Since this is using the built-in mechanism to determine if a value was sent, there is no additional performance penalty for setting the default values in Huma. #### What's Changed - Update request-resolvers.md by [@​alexanderilyin](https://redirect.github.com/alexanderilyin) in [https://github.com/danielgtaylor/huma/pull/619](https://redirect.github.com/danielgtaylor/huma/pull/619) - docs: fix YAML command example by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/624](https://redirect.github.com/danielgtaylor/huma/pull/624) - feat: case-insensitive field matching for JSON/CBOR by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/629](https://redirect.github.com/danielgtaylor/huma/pull/629) - feat: allow scalar pointers with defaults by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/633](https://redirect.github.com/danielgtaylor/huma/pull/633) - Update build-sdk.sh by [@​MaximeWeyl](https://redirect.github.com/MaximeWeyl) in [https://github.com/danielgtaylor/huma/pull/637](https://redirect.github.com/danielgtaylor/huma/pull/637) #### New Contributors - [@​MaximeWeyl](https://redirect.github.com/MaximeWeyl) made their first contribution in [https://github.com/danielgtaylor/huma/pull/637](https://redirect.github.com/danielgtaylor/huma/pull/637) **Full Changelog**: https://github.com/danielgtaylor/huma/compare/v2.24.0...v2.25.0 ### [`v2.24.0`](https://redirect.github.com/danielgtaylor/huma/releases/tag/v2.24.0) [Compare Source](https://redirect.github.com/danielgtaylor/huma/compare/v2.23.0...v2.24.0) #### Overview ##### Better Support of String Subtype Slice Params It's now possible to use types based on `string` like you commonly see for enumerations as slice inputs to Huma operations. ```go type MyEnum string const ( Value1 MyEnum = "value1" Value2 MyEnum = "value2" // ... ) huma.Get(api, "/example", func(ctx context.Context, input *struct{ Example []MyEnum `query:"example" enum:"value1,value2"` }) (*struct{}, error) { // ... } ``` ##### Better Support of non-Object Refs Fixes a bug that prevented deliberate refs of nullable non-objects from being used due to a panic. It's now possible to do something like this to automatically add enum values from a type when generating the schema and use a `$ref` in the JSON Schema: ```go type InstitutionKind string const ( Lab InstitutionKind = "Lab" FoundingAgency InstitutionKind = "FundingAgency" SequencingPlatform InstitutionKind = "SequencingPlatform" Other InstitutionKind = "Other" ) var InstitutionKindValues = []InstitutionKind{ Lab, FoundingAgency, SequencingPlatform, Other, } // Register enum in OpenAPI specification func (u InstitutionKind) Schema(r huma.Registry) *huma.Schema { if r.Map()["InstitutionKind"] == nil { schemaRef := r.Schema(reflect.TypeOf(""), false, "InstitutionKind") schemaRef.Title = "InstitutionKind" for _, v := range InstitutionKindValues { schemaRef.Enum = append(schemaRef.Enum, string(v)) } r.Map()["InstitutionKind"] = schemaRef } return &huma.Schema{Ref: "#/components/schemas/InstitutionKind"} } ``` ##### Fix Empty Security Marshaling The empty security object has semantic meaning in OpenAPI 3.x which enables you to override a global security setting to make one or more operations public. It's now possible to do so: ```go huma.Register(api, huma.Operation{ OperationID: "GetUser", Method: http.MethodGet, Path: "/user/{id}", Security: []map[string][]string{}, // This will not require security! }, func(ctx context.Context, input *GetUserInput) (*GetUserOutput, error) { resp := &GetUserOutput{} resp.Body.Message = "GetUser with ID: " + input.ID + " works!" return resp, nil }) ``` ##### Expanded Adapter Interface The `huma.Adapter` interface now has methods for getting the HTTP version and TLS info of the incoming request, which enables better tracing middleware using e.g. OpenTelemetry. ##### Schema Transformers Automatically Call `schema.PrecomputeMessages()` Schema transformers may modify the schema in ways that precomputed messages & validation cache data are no longer valid. This change makes sure to recompute them if the schema has been modified, preventing potential panics. ##### Configurable Array Nullability [Huma v2.20.0](https://redirect.github.com/danielgtaylor/huma/releases/tag/v2.20.0) introduced nullable JSON Schema arrays for Go slices due to the default behavior of Go's JSON marshaler. This change resulted in some clients (e.g. Typescript) now needing to do extra checks even when the service is sure it will never return a `nil` slice. This release includes a way to change the global default Huma behavior by setting `huma.DefaultArrayNullable = false`. It is still possible to set `nullable` on each field to override this behavior, but now it is easier to do so globally for those who wish to use the old (arguably less correct) behavior. ##### Better SSE Support This release includes some `http.ResponseController` behavior to unwrap response writers to try and get access to `SetWriteDeadline` and `Flush` methods on response writers. This prevents error messages from being dumped into the console and enables Gin SSE support for the first time with the Huma `sse` package. Most routers should Just Work :tm: with SSE now. ##### Read-Only & Write-Only Behavior Clarification The read and write-only behavior of Huma validation has been clarified in the docs. See https://huma.rocks/features/request-validation/#read-and-write-only to ensure it works as you expect. #### What's Changed - Fix typo in request-inputs.md by [@​j0urneyK](https://redirect.github.com/j0urneyK) in [https://github.com/danielgtaylor/huma/pull/591](https://redirect.github.com/danielgtaylor/huma/pull/591) - refactor: use type switch instead of if-else by [@​alexandear](https://redirect.github.com/alexandear) in [https://github.com/danielgtaylor/huma/pull/595](https://redirect.github.com/danielgtaylor/huma/pull/595) - chore: enable dupword; fix appeared lint issues by [@​alexandear](https://redirect.github.com/alexandear) in [https://github.com/danielgtaylor/huma/pull/598](https://redirect.github.com/danielgtaylor/huma/pull/598) - docs: fix typos in docs, comments, and tests by [@​alexandear](https://redirect.github.com/alexandear) in [https://github.com/danielgtaylor/huma/pull/596](https://redirect.github.com/danielgtaylor/huma/pull/596) - fix: panic - allow for parameters to be subtype of string by [@​hlavavit](https://redirect.github.com/hlavavit) in [https://github.com/danielgtaylor/huma/pull/592](https://redirect.github.com/danielgtaylor/huma/pull/592) - fix: check actual type in schema ref when enforcing non-nullable object schemas by [@​lsdch](https://redirect.github.com/lsdch) in [https://github.com/danielgtaylor/huma/pull/599](https://redirect.github.com/danielgtaylor/huma/pull/599) - fix: dependency upgrades, fixes [#​569](https://redirect.github.com/danielgtaylor/huma/issues/569) by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/601](https://redirect.github.com/danielgtaylor/huma/pull/601) - docs: add new testimonial to README by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/602](https://redirect.github.com/danielgtaylor/huma/pull/602) - fix: marshal empty security object by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/603](https://redirect.github.com/danielgtaylor/huma/pull/603) - docs: add info about read/write only behavior by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/608](https://redirect.github.com/danielgtaylor/huma/pull/608) - docs: add note about required write-only field by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/609](https://redirect.github.com/danielgtaylor/huma/pull/609) - Add api version and tls to adapter by [@​fntz](https://redirect.github.com/fntz) in [https://github.com/danielgtaylor/huma/pull/610](https://redirect.github.com/danielgtaylor/huma/pull/610) - fix: recompute property names after schema transform by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/611](https://redirect.github.com/danielgtaylor/huma/pull/611) - fix: make nullable arrays configurable by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/612](https://redirect.github.com/danielgtaylor/huma/pull/612) - Update your-first-api.md by [@​alexanderilyin](https://redirect.github.com/alexanderilyin) in [https://github.com/danielgtaylor/huma/pull/615](https://redirect.github.com/danielgtaylor/huma/pull/615) - feat: unwrap resp for better deadline/flush SSE support by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/613](https://redirect.github.com/danielgtaylor/huma/pull/613) #### New Contributors - [@​j0urneyK](https://redirect.github.com/j0urneyK) made their first contribution in [https://github.com/danielgtaylor/huma/pull/591](https://redirect.github.com/danielgtaylor/huma/pull/591) - [@​alexandear](https://redirect.github.com/alexandear) made their first contribution in [https://github.com/danielgtaylor/huma/pull/595](https://redirect.github.com/danielgtaylor/huma/pull/595) - [@​hlavavit](https://redirect.github.com/hlavavit) made their first contribution in [https://github.com/danielgtaylor/huma/pull/592](https://redirect.github.com/danielgtaylor/huma/pull/592) - [@​fntz](https://redirect.github.com/fntz) made their first contribution in [https://github.com/danielgtaylor/huma/pull/610](https://redirect.github.com/danielgtaylor/huma/pull/610) - [@​alexanderilyin](https://redirect.github.com/alexanderilyin) made their first contribution in [https://github.com/danielgtaylor/huma/pull/615](https://redirect.github.com/danielgtaylor/huma/pull/615) **Full Changelog**: https://github.com/danielgtaylor/huma/compare/v2.23.0...v2.24.0 ### [`v2.23.0`](https://redirect.github.com/danielgtaylor/huma/releases/tag/v2.23.0) [Compare Source](https://redirect.github.com/danielgtaylor/huma/compare/v2.22.1...v2.23.0) #### Overview ##### Pointers for Non-Param Fields It's now possible to use pointers for non-param fields in input structs without Huma complaining. For example, here the `User` is not a path/query/header param and is populated from the `Authorization` header value for use later: ```go type EndpointInput struct { Token string `header:"Authorization"` User *User } func (i *EndpointInput) Resolve(ctx huma.Context) []error { user, token_valid := ValidateToken(i.Token) // user is nil if token is missing or invalid i.User = user return nil } ``` ##### Hidden Field Validation Hidden fields are now validated properly if they are present in the input. For example: ```go huma.Put(api, "/demo", func(ctx context.Context, input *struct{ Body struct { Field1 string `json:"field1" Field2 int `json:"field2" hidden:"true" minimum:"10"` } }) (*MyResponse, error) { // If `input.Field2` is sent by the client, the request will fail // if its value is below 10 due to the validation schema. return &MyResponse{...}, nil }) ``` ##### Prevent Overwriting Schema Validations All validations now take the existing value of the validator as input when generating the schema, which means a `SchemaProvider` or `SchemaTransformer` output won't get overwritten when generating schemas. This fixes a bug that was partially fixed but missed several important fields like `pattern`. ##### Non-Addressable Resolver It's now possible to use non-addressable types which implement `Resolver`, such as custom primitive types as map keys. This is currently a little less efficient as a pointer to the type needs to be generated, but at least it is now possible and performance can be improved in the future. ##### Use the Status Code from `NewError` When providing your own custom `huma.NewError` function, the resulting error's status code was ignored. This has been fixed to be used as the output status code, enabling the function to modify the status code before going out on the wire. ##### NewError with a Context It's now possible to replace `huma.NewErrorWithContext` so your error generation function has access to the underlying request context. ##### NewWithPrefix & Servers When using `humago.NewWithPrefix` and not providing any servers, a single server entry is now generated for you with the given prefix. ##### Support `url.URL` Parameters You can now use a URL as an input path/query/header parameter and it will be parsed/validated for you. ##### Request Body Generation Improvements Like response body generation, the request body generation has been improved to generate missing pieces of the body OpenAPI structure. This enables you to easily e.g. add a description but have Huma still generate the JSON Schema for you. Example: ```go func (tr TEERouter) RegisterRoutes(api huma.API) { operation := huma.Operation{ Method: http.MethodPost, Path: "/tee", Summary: "TEE", Description: "TEE description", RequestBody: &huma.RequestBody{ Description: "My custom request schema", }, } huma.Register(api, operation, tr.CalculateTEE) } ``` #### What's Changed - Allow using pointers for non param fields in input structs by [@​lsdch](https://redirect.github.com/lsdch) in [https://github.com/danielgtaylor/huma/pull/565](https://redirect.github.com/danielgtaylor/huma/pull/565) - fix: validate hidden fields by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/573](https://redirect.github.com/danielgtaylor/huma/pull/573) - fix: prevent overwriting schema validations by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/575](https://redirect.github.com/danielgtaylor/huma/pull/575) - fix: support non-addressable resolver values by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/580](https://redirect.github.com/danielgtaylor/huma/pull/580) - fix: use status code returned from NewError when writing errors by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/581](https://redirect.github.com/danielgtaylor/huma/pull/581) - add NewErrorWithContext by [@​nunoo](https://redirect.github.com/nunoo) in [https://github.com/danielgtaylor/huma/pull/582](https://redirect.github.com/danielgtaylor/huma/pull/582) - Add default Server object when calling humago.NewWithPrefix by [@​yursan9](https://redirect.github.com/yursan9) in [https://github.com/danielgtaylor/huma/pull/579](https://redirect.github.com/danielgtaylor/huma/pull/579) - fix: unsupported param type url.URL by [@​ddl-ebrown](https://redirect.github.com/ddl-ebrown) in [https://github.com/danielgtaylor/huma/pull/584](https://redirect.github.com/danielgtaylor/huma/pull/584) - fix: allow setting request description and still gen schema by [@​danielgtaylor](https://redirect.github.com/danielgtaylor) in [https://github.com/danielgtaylor/huma/pull/587](https://redirect.github.com/danielgtaylor/huma/pull/587) #### New Contributors - [@​yursan9](https://redirect.github.com/yursan9) made their first contribution in [https://github.com/danielgtaylor/huma/pull/579](https://redirect.github.com/danielgtaylor/huma/pull/579) - [@​ddl-ebrown](https://redirect.github.com/ddl-ebrown) made their first contribution in [https://github.com/danielgtaylor/huma/pull/584](https://redirect.github.com/danielgtaylor/huma/pull/584) **Full Changelog**: https://github.com/danielgtaylor/huma/compare/v2.22.1...v2.23.0

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.



This PR was generated by Mend Renovate. View the repository job log.

renovate[bot] commented 1 week ago

ℹ Artifact update notice

File name: backend/go.mod

In order to perform the update(s) described in the table above, Renovate ran the go get command, which resulted in the following additional change(s):

Details:

Package Change
github.com/klauspost/compress v1.17.7 -> v1.17.10
golang.org/x/crypto v0.27.0 -> v0.28.0
golang.org/x/sys v0.25.0 -> v0.26.0
golang.org/x/text v0.18.0 -> v0.19.0
codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Flag Coverage Δ
backend 36.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend 36.94% <ø> (ø)
Backend build tools 0.00% <ø> (ø)
Web Application 23.33% <ø> (ø)
Android Application 0.00% <ø> (ø)