Skip to content

Commit

Permalink
Merge pull request #1076 from Zerotask/patch-1
Browse files Browse the repository at this point in the history
docs(operations): minor adjustments
  • Loading branch information
vitalik committed Apr 30, 2024
2 parents e69baef + 68e61ee commit 9efa6aa
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions docs/docs/guides/input/operations.md
Expand Up @@ -2,14 +2,13 @@

## Defining operations

An "Operation" can be one of the HTTP "methods":
An `operation` can be one of the following [HTTP methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods):

- GET
- POST
- PUT
- DELETE
- PATCH
- ... and more

**Django Ninja** comes with a decorator for each operation:

Expand All @@ -35,26 +34,25 @@ def patch_operation(request):
...
```

See the [Operations parameters](../../reference/operations-parameters.md)
See the [operations parameters](../../reference/operations-parameters.md)
reference docs for information on what you can pass to any of these decorators.


## Handling multiple methods

If you need to handle multiple methods with a single function for a given path,
you can use the `api_operation` decorator:

```python hl_lines="1"
@api.api_operation(["POST", "PATCH"], "/path")
def mixed(request):
def mixed_operation(request):
...
```

This feature can also be used to implement other HTTP methods that don't have
corresponding django-ninja methods, such as `HEAD` or `OPTIONS`.
corresponding **Django Ninja** methods, such as `HEAD` or `OPTIONS`.

```python hl_lines="1"
@api.api_operation(["HEAD", "OPTIONS"], "/path")
def mixed(request):
def mixed_operation(request):
...
```

0 comments on commit 9efa6aa

Please sign in to comment.