Skip to content

Commit

Permalink
Merge pull request #596 from alexandear/docs/fix-typos
Browse files Browse the repository at this point in the history
docs: fix typos in docs, comments, and tests
  • Loading branch information
danielgtaylor authored Oct 4, 2024
2 parents ea829ae + 6116f49 commit 4866d9c
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion adapters/humaflow/flow/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestMatching(t *testing.T) {
"GET", "/not/enough",
http.StatusNotFound, nil, "",
},
// wilcards
// wildcards
{
[]string{"GET"}, "/prefix/...",
"GET", "/prefix/anything/else",
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/features/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/features/request-inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/features/request-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/features/schema-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how-to/oauth2-jwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions humacli/humacli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
2 changes: 1 addition & 1 deletion openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`

Expand Down
4 changes: 2 additions & 2 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,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}
}
Expand Down Expand Up @@ -893,7 +893,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
}

Expand Down
2 changes: 1 addition & 1 deletion sse/sse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4866d9c

Please sign in to comment.