Skip to content

Commit

Permalink
Revert test change
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Dec 14, 2023
1 parent ec90c8a commit 15b7856
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 4 additions & 4 deletions docs/handlers.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ async def get_article() -> Ok[Article]:

### Returning Multiple Status Codes

If your handler can return multiple status codes, use a union of _uapi_ response types.
Use a union of _uapi_ response types if your handler can return multiple status codes.

All responses defined this way will be rendered in the OpenAPI schema.

Expand All @@ -532,8 +532,8 @@ async def user_profile() -> Ok[Profile] | NoContent:
### _uapi_ ResponseExceptions

Any raised instances of {class}`uapi.ResponseException` will be caught and transformed into a proper response.
Like any exception, ResponseExceptions short-circuit handlers so they can be useful for validation and middleware.
In other cases, simply returning a response instead is cheaper and usually more type-safe.
Like any exception, `ResponseExceptions` short-circuit handlers so they can be useful for validation and middleware.
In other cases, simply returning a response is faster and usually more type-safe.

ResponseExceptions contain instances of _uapi_ status code classes and so can return rich response data, just like any normal response.

Expand All @@ -549,7 +549,7 @@ async def get_article() -> Ok[Article]:
...
```

Since exceptions don't show up in the handler signature, they won't be present in the generated OpenAPI schema.
Since exceptions don't show up in the handler signature they won't be present in the generated OpenAPI schema.
If you need them to, you can add the actual response type into the handler response signature as part of a union:

```python
Expand Down
6 changes: 1 addition & 5 deletions tests/openapi/test_shorthands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ class OpenAPIDateTime(DatetimeShorthand):
def make_openapi_response() -> Response | None:
return Response(
"DESC",
{
"application/date": MediaType(
Schema(Schema.Type.STRING, format="datetime")
)
},
{"test": MediaType(Schema(Schema.Type.STRING, format="datetime"))},
)

app = App()
Expand Down

0 comments on commit 15b7856

Please sign in to comment.