Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API browser does not support more complex type anotations #371

Open
Talkless opened this issue Mar 7, 2023 · 1 comment
Open

API browser does not support more complex type anotations #371

Talkless opened this issue Mar 7, 2023 · 1 comment

Comments

@Talkless
Copy link
Contributor

Talkless commented Mar 7, 2023

For example if we have function using Unions, Optionals:

@jsonrpc_client.method('object.trip_stop')
@jwt_required()
def object__trip_stop(
        object_id: Union[int, List[int]],
        time_from: str,
        time_to: str,
        min_moving: Optional[int] = 1,
        min_stationary: Optional[int] = 10,
        zones: Optional[List[int]] = [0],
        time_ranges: Optional[List[List[Union[int, str, str]]]] = [],
        zones_only: Optional[bool] = False,
        trip_mode: Optional[int] = 3,
        trips_stops: Optional[int] = 3
) -> Optional[str]:

We get documentation with just Objects:
image

@nycholas
Copy link
Member

👋 This PR added support to serializable direct classes Python with the default constructor, Python dataclasses, and Pydantic models, see [here](https://github.com/cenobites/flask-jsonrpc/ blob/master/examples/pydantic/run.py#L158) and example of use. The next step is to enhance the schema to reflect the object at the API Browser and be recognized by it.

Payload:

{
    "jsonrpc": "2.0",
    "method": "Petstore.create_pet",
    "params": {
        "pet": {
            "name": "Lou",
            "tag": "dog"
        }
    },
    "id": "5ad1d47f-4e6c-4f24-bfa9-18a3ec340c57"
}
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants