Skip to content

Commit

Permalink
Added more information about deprecated endpoint to README (0b0100100…
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlczech authored Jun 26, 2023
1 parent ac6143e commit 82ff248
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ Check the [examples](/examples) folder.

1. Define your data structure used in (query, json, headers, cookies, resp) with `pydantic.BaseModel`
2. create `spectree.SpecTree` instance with the web framework name you are using, like `api = SpecTree('flask')`
3. `api.validate` decorate the route with
3. `api.validate` decorate the route with (the default value is given in parentheses):
* `query`
* `json`
* `headers`
* `cookies`
* `resp`
* `tags`
* `security`
* `tags` *(no tags on endpoint)*
* `security` *(`None` - endpoint is not secured)*
* `deprecated` *(`False` - endpoint is not marked as deprecated)*
4. access these data with `context(query, json, headers, cookies)` (of course, you can access these from the original place where the framework offered)
* flask: `request.context`
* falcon: `req.context`
Expand Down Expand Up @@ -215,6 +216,20 @@ def foobar():
</p>
</details>

> How to mark deprecated endpoint?
Use `deprecated` attribute with value `True` in `api.validate()` decorator. This way, an endpoint will be marked as
deprecated and will be marked with a strikethrough in API documentation.

Code example:
```
@api.validate(
deprecated=True,
)
def depreated_endpoint():
...
```

> What should I return when I'm using the library?
No need to change anything. Just return what the framework required.
Expand Down
2 changes: 1 addition & 1 deletion spectree/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def validate(
:param resp: `spectree.Response`
:param tags: a tuple of strings or :class:`spectree.models.Tag`
:param security: dict with security config for current route and method
:param deprecated: bool if endpoint is marked as deprecated
:param deprecated: bool, if endpoint is marked as deprecated
:param before: :meth:`spectree.utils.default_before_handler` for
specific endpoint
:param after: :meth:`spectree.utils.default_after_handler` for
Expand Down

0 comments on commit 82ff248

Please sign in to comment.