-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from danielgtaylor/reduce-deps
feat: significantly reduce dependencies
- Loading branch information
Showing
24 changed files
with
2,728 additions
and
1,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Example field selection transform enabling a GraphQL-like behavior. | ||
package fields | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/danielgtaylor/huma/v2" | ||
"github.com/danielgtaylor/shorthand/v2" | ||
) | ||
|
||
// FieldSelectTransform is an example of a transform that can use an input | ||
// header value to modify the response on the server, providing a GraphQL-like | ||
// way to send only the fields that the client wants over the wire. | ||
func FieldSelectTransform(ctx huma.Context, status string, v any) (any, error) { | ||
if fields := ctx.Header("Fields"); fields != "" { | ||
// Ugh this is inefficient... consider other ways of doing this :-( | ||
var tmp any | ||
b, _ := json.Marshal(v) | ||
json.Unmarshal(b, &tmp) | ||
result, _, err := shorthand.GetPath(fields, tmp, shorthand.GetOptions{}) | ||
return result, err | ||
} | ||
return v, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module github.com/danielgtaylor/huma/v2/examples | ||
|
||
go 1.20 | ||
|
||
replace github.com/danielgtaylor/huma/v2 => ../ | ||
|
||
require ( | ||
github.com/danielgtaylor/huma v1.14.2 | ||
github.com/danielgtaylor/huma/v2 v2.0.0-00010101000000-000000000000 | ||
github.com/danielgtaylor/shorthand/v2 v2.2.0 | ||
github.com/go-chi/chi v4.1.2+incompatible | ||
github.com/go-chi/chi/v5 v5.0.11 | ||
github.com/spf13/cobra v1.8.0 | ||
google.golang.org/protobuf v1.32.0 | ||
) | ||
|
||
require ( | ||
github.com/Jeffail/gabs/v2 v2.6.1 // indirect | ||
github.com/andybalholm/brotli v1.1.0 // indirect | ||
github.com/danielgtaylor/casing v0.0.0-20210126043903-4e55e6373ac3 // indirect | ||
github.com/danielgtaylor/mexpr v1.9.0 // indirect | ||
github.com/evanphx/json-patch/v5 v5.9.0 // indirect | ||
github.com/fatih/color v1.15.0 // indirect | ||
github.com/fatih/structs v1.1.0 // indirect | ||
github.com/fsnotify/fsnotify v1.6.0 // indirect | ||
github.com/fxamacker/cbor/v2 v2.5.0 // indirect | ||
github.com/goccy/go-yaml v1.11.2 // indirect | ||
github.com/graphql-go/graphql v0.8.0 // indirect | ||
github.com/graphql-go/handler v0.2.3 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/koron-go/gqlcost v0.2.2 // indirect | ||
github.com/magiconair/properties v1.8.7 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/opentracing/opentracing-go v1.2.0 // indirect | ||
github.com/pelletier/go-toml/v2 v2.1.1 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/spf13/afero v1.9.5 // indirect | ||
github.com/spf13/cast v1.5.1 // indirect | ||
github.com/spf13/jwalterweatherman v1.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/spf13/viper v1.15.0 // indirect | ||
github.com/subosito/gotenv v1.4.2 // indirect | ||
github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9 // indirect | ||
github.com/x448/float16 v0.8.4 // indirect | ||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect | ||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect | ||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect | ||
go.uber.org/atomic v1.9.0 // indirect | ||
go.uber.org/multierr v1.8.0 // indirect | ||
go.uber.org/zap v1.21.0 // indirect | ||
golang.org/x/sys v0.16.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect | ||
gopkg.in/ini.v1 v1.67.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
Oops, something went wrong.