From 6116f49d4abec1877d51049fc079d9d36d30bc46 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Thu, 3 Oct 2024 12:00:22 +0300 Subject: [PATCH] docs: fix typos in docs, comments, and tests --- adapters/humaflow/flow/flow_test.go | 2 +- docs/docs/features/cli.md | 4 ++-- docs/docs/features/request-inputs.md | 2 +- docs/docs/features/request-validation.md | 4 ++-- docs/docs/features/schema-customization.md | 2 +- docs/docs/how-to/oauth2-jwt.md | 2 +- humacli/humacli_test.go | 4 ++-- openapi.go | 2 +- schema.go | 4 ++-- sse/sse_test.go | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/adapters/humaflow/flow/flow_test.go b/adapters/humaflow/flow/flow_test.go index 854711e9..a12bf9fb 100644 --- a/adapters/humaflow/flow/flow_test.go +++ b/adapters/humaflow/flow/flow_test.go @@ -53,7 +53,7 @@ func TestMatching(t *testing.T) { "GET", "/not/enough", http.StatusNotFound, nil, "", }, - // wilcards + // wildcards { []string{"GET"}, "/prefix/...", "GET", "/prefix/anything/else", diff --git a/docs/docs/features/cli.md b/docs/docs/features/cli.md index 0bd609f5..6ee8eecc 100644 --- a/docs/docs/features/cli.md +++ b/docs/docs/features/cli.md @@ -151,11 +151,11 @@ Now you can run your service and use the new command: `go run . openapi`. Notice ### Custom Commands with Options -If you want to access your custom options struct with custom commands, use the [`huma.WithOptions(func(cmd *cobra.Command, args []string, options *YourOptions)) func(cmd *cobra.Command, args []string)`](https://pkg.go.dev/github.com/danielgtaylor/huma/v2#WithOptions) utitity function. It ensures the options are parsed and available before running your command. +If you want to access your custom options struct with custom commands, use the [`huma.WithOptions(func(cmd *cobra.Command, args []string, options *YourOptions)) func(cmd *cobra.Command, args []string)`](https://pkg.go.dev/github.com/danielgtaylor/huma/v2#WithOptions) utility function. It ensures the options are parsed and available before running your command. !!! info "More Customization" - You can also overwite `cli.Root().Run` to completely customize how you run the server. Or just ditch the `cli` package altogether! + You can also overwrite `cli.Root().Run` to completely customize how you run the server. Or just ditch the `cli` package altogether! ## App Name & Version diff --git a/docs/docs/features/request-inputs.md b/docs/docs/features/request-inputs.md index 20d919e3..5201527c 100644 --- a/docs/docs/features/request-inputs.md +++ b/docs/docs/features/request-inputs.md @@ -33,7 +33,7 @@ The following parameter types are supported out of the box: | `time.Time` | `2020-01-01T12:00:00Z` | | slice, e.g. `[]int` | `1,2,3`, `tag1,tag2` | -For example, if the parameter is a query param and the type is `[]string` it might look like `?tags=tag1,tag2` in the URI. Query paramaters also support specifying the same parameter multiple times by setting the `explode` tag, e.g. `query:"tags,explode"` would parse a query string like `?tags=tag1&tags=tag2` instead of a comma separated list. The comma separated list is faster and recommended for most use cases. +For example, if the parameter is a query param and the type is `[]string` it might look like `?tags=tag1,tag2` in the URI. Query parameters also support specifying the same parameter multiple times by setting the `explode` tag, e.g. `query:"tags,explode"` would parse a query string like `?tags=tag1&tags=tag2` instead of a comma separated list. The comma separated list is faster and recommended for most use cases. For cookies, the default behavior is to read the cookie _value_ from the request and convert it to one of the types above. If you want to access the entire cookie, you can use `http.Cookie` as the type instead: diff --git a/docs/docs/features/request-validation.md b/docs/docs/features/request-validation.md index 67ed148c..9845984a 100644 --- a/docs/docs/features/request-validation.md +++ b/docs/docs/features/request-validation.md @@ -21,7 +21,7 @@ The standard `json` tag is supported and can be used to rename a field. Any fiel ## Optional / Required -Fields being optional/required is determined automatically but can be overidden as needed using the logic below: +Fields being optional/required is determined automatically but can be overridden as needed using the logic below: 1. Start with all fields required. 2. If a field has `omitempty`, it is optional. @@ -54,7 +54,7 @@ In many languages (including Go), there is little to no distinction between an e Huma tries to balance schema simplicity, usability, and broad compatibility with schema correctness and a broad range of language support for end-to-end API tooling. To that end, it supports field nullability to a limited extent, and future changes may modify this default behavior as tools become more compatible with advanced JSON Schema features. -Fields being nullable is determined automatically but can be overidden as needed using the logic below: +Fields being nullable is determined automatically but can be overridden as needed using the logic below: 1. Start with no fields as nullable 2. If a field is a pointer: diff --git a/docs/docs/features/schema-customization.md b/docs/docs/features/schema-customization.md index d70844b1..530d94cd 100644 --- a/docs/docs/features/schema-customization.md +++ b/docs/docs/features/schema-customization.md @@ -52,7 +52,7 @@ type SchemaProvider interface { } ``` -The [`huma.Registry`](https://pkg.go.dev/github.com/danielgtaylor/huma/v2#Registry) is passed to you and can be used to get schemas or refs for any embedded structs. Here is an example, where we want to know if a field was omitted vs. null vs. a value when sent as part of a request body. First we start by defininig the custom generic struct: +The [`huma.Registry`](https://pkg.go.dev/github.com/danielgtaylor/huma/v2#Registry) is passed to you and can be used to get schemas or refs for any embedded structs. Here is an example, where we want to know if a field was omitted vs. null vs. a value when sent as part of a request body. First we start by defining the custom generic struct: ```go title="code.go" // OmittableNullable is a field which can be omitted from the input, diff --git a/docs/docs/how-to/oauth2-jwt.md b/docs/docs/how-to/oauth2-jwt.md index 3b8fd16c..4273ff46 100644 --- a/docs/docs/how-to/oauth2-jwt.md +++ b/docs/docs/how-to/oauth2-jwt.md @@ -110,7 +110,7 @@ graph LR APIGateway --->|Forward| API ``` -In this case and depending on your security requirements, you may be able to skip this section since all incoming requests to your API will have already been vetted by the gateway. In this scenario, the Huma code frome the previous section serves mostly as documentation for your clients. +In this case and depending on your security requirements, you may be able to skip this section since all incoming requests to your API will have already been vetted by the gateway. In this scenario, the Huma code from the previous section serves mostly as documentation for your clients. ### Huma Auth Middleware diff --git a/humacli/humacli_test.go b/humacli/humacli_test.go index 91b41a05..f4542896 100644 --- a/humacli/humacli_test.go +++ b/humacli/humacli_test.go @@ -73,14 +73,14 @@ func TestCLIPlain(t *testing.T) { Port int // ignore private fields, should not crash. - ingore bool + ignore bool } cli := humacli.New(func(hooks humacli.Hooks, options *Options) { assert.True(t, options.Debug) assert.Equal(t, "localhost", options.Host) assert.Equal(t, 8001, options.Port) - assert.False(t, options.ingore) + assert.False(t, options.ignore) hooks.OnStart(func() { // Do nothing }) diff --git a/openapi.go b/openapi.go index b978ed75..4a8106a6 100644 --- a/openapi.go +++ b/openapi.go @@ -835,7 +835,7 @@ type Operation struct { // BodyReadTimeout is the maximum amount of time to wait for the request // body to be read. If not specified, the default is 5 seconds. Use -1 // for unlimited. If the timeout is reached, then an HTTP 408 error is - // returned. This value supercedes the server's read timeout, and a value + // returned. This value supersedes the server's read timeout, and a value // of -1 can unset the server's timeout. BodyReadTimeout time.Duration `yaml:"-"` diff --git a/schema.go b/schema.go index b1e9b288..8610abbf 100644 --- a/schema.go +++ b/schema.go @@ -707,7 +707,7 @@ func schemaFromType(r Registry, t reflect.Type) *Schema { if _, ok := v.(encoding.TextUnmarshaler); ok { // Special case: types that implement encoding.TextUnmarshaler are able to // be loaded from plain text, and so should be treated as strings. - // This behavior can be overidden by implementing `huma.SchemaProvider` + // This behavior can be overridden by implementing `huma.SchemaProvider` // and returning a custom schema. return &Schema{Type: TypeString, Nullable: isPointer} } @@ -892,7 +892,7 @@ func schemaFromType(r Registry, t reflect.Type) *Schema { switch s.Type { case TypeBoolean, TypeInteger, TypeNumber, TypeString: // Scalar types which are pointers are nullable by default. This can be - // overidden via the `nullable:"false"` field tag in structs. + // overridden via the `nullable:"false"` field tag in structs. s.Nullable = isPointer } diff --git a/sse/sse_test.go b/sse/sse_test.go index 4cfc46c1..158a9a8f 100644 --- a/sse/sse_test.go +++ b/sse/sse_test.go @@ -96,7 +96,7 @@ data: {"error": "encode error: json: unsupported type: chan int"} `, resp.Body.String()) - // Test write error doens't panic + // Test write error doesn't panic w := &DummyWriter{writeErr: errors.New("whoops")} req, _ := http.NewRequest(http.MethodGet, "/sse", nil) api.Adapter().ServeHTTP(w, req)