-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make some updates for when 4.4 is released
- Loading branch information
1 parent
e4cd380
commit 7b8612e
Showing
17 changed files
with
268 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"label": "Developer Guide", | ||
"position": 3 | ||
"position": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
content/platform/developer_guide/disabling_output_validation.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
--- | ||
title: Disabling Output Validation | ||
sidebar_position: 4 | ||
description: This page provides instructions for disabling output validation, when defining a new router function. | ||
keywords: | ||
- Validation | ||
- Pydantic | ||
- Python | ||
- Development | ||
- OpenBB Platform | ||
- Provider Interface | ||
- Router | ||
- Custom | ||
- Commands | ||
- FastAPI | ||
- extensions | ||
--- | ||
|
||
import HeadTitle from '@site/src/components/General/HeadTitle.tsx'; | ||
|
||
<HeadTitle title="Disabling Output Validation - Developer Guides | OpenBB Platform Docs" /> | ||
|
||
In some cases, it may be desirable to disable output validation for a custom router endpoint. | ||
The example below demonstrates how to do it within your own custom router path. | ||
|
||
:::important | ||
This section refers to settings available beginning OpenBB v4.4.0 | ||
::: | ||
|
||
In boths functions, the output will be typed as "Any", regardless of what the `return` definition states. | ||
|
||
Within the `@router.command` decorator, add the keyword argument: | ||
|
||
```python | ||
no_validate = True | ||
``` | ||
|
||
## Example | ||
|
||
This example assumes that ficticious extensions have been defined and installed. | ||
|
||
```python | ||
from datetime import datetime | ||
|
||
from openbb_core.app.model.command_context import CommandContext | ||
from openbb_core.app.model.example import APIEx, PythonEx | ||
from openbb_core.app.model.obbject import OBBject | ||
from openbb_core.app.provider_interface import ( | ||
ExtraParams, | ||
ProviderChoices, | ||
StandardParams, | ||
) | ||
from openbb_core.app.query import Query | ||
from openbb_core.app.router import Router | ||
from openbb_core.provider.abstract.data import Data | ||
|
||
router = Router(prefix="", description="Some OpenBB Router Extension.") | ||
|
||
# This uses the Provider Interface. | ||
@router.command( | ||
model="SomeModel", | ||
no_validate=True, | ||
examples=[ | ||
APIEx(parameters={"provider": "some_provider"}), | ||
PythonEx( | ||
description="Say Hello.", | ||
code=[ | ||
"result = obb.some_extension.some_provider_function()", | ||
], | ||
), | ||
], | ||
) | ||
async def some_provider_function( | ||
cc: CommandContext, | ||
provider_choices: ProviderChoices, | ||
standard_params: StandardParams, | ||
extra_params: ExtraParams, | ||
) -> OBBject[Data]: | ||
"""Some function using the Provider Interface.""" | ||
obbject = await OBBject.from_query(Query(**locals())) | ||
|
||
new_output = [] | ||
results = obbject.results | ||
|
||
# Do something with results and append to `new_output` list. | ||
|
||
return new_output | ||
|
||
|
||
# This is a standard router "get" command. | ||
@router.command( | ||
methods=["GET"], | ||
no_validate=True | ||
examples=[ | ||
PythonEx( | ||
description="Say Hello.", | ||
code=[ | ||
"result = obb.some_extension.hello()", | ||
], | ||
), | ||
], | ||
) | ||
async def hello() -> ( | ||
Any | ||
): | ||
"""Hello World.""" | ||
return { | ||
datetime.now().strftime( | ||
"%Y-%m-%d" | ||
): "Hello from the Empty Router extension!" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"label": "Getting Started", | ||
"position": 2 | ||
"position": 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.