Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
VishnuSanal committed Sep 28, 2024
1 parent c41cd66 commit d0b0a8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions docs_src/src/pages/documentation/api_reference/openapi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ python app.py --disable-openapi

## How to use?

- Query Params: The typing for query params can be added as `def get(r: Request, query_params=GetRequestParams)` where `GetRequestParams` is a subclass of `QueryParams`
- Query Params: The typing for query params can be added as `def get(r: Request, query_params=GetRequestParams)` where `GetRequestParams` is a subclass of `RequestQuery`
- Path Params are defaulted to string type (ref: https://en.wikipedia.org/wiki/Query_string)

<CodeGroup title="Basic App">

```python {{ title: 'untyped' }}
from robyn.types import RequestBody, QueryParams
from robyn.types import RequestBody, RequestQuery

from robyn import Robyn, OpenAPI
from robyn.openapi import OpenAPIInfo, Contact, License, ExternalDocumentation, Components
Expand Down Expand Up @@ -61,7 +61,7 @@ async def welcome():
return "hi"


class GetRequestParams(QueryParams):
class GetRequestParams(RequestQuery):
appointment_id: str
year: int

Expand All @@ -83,7 +83,7 @@ if __name__ == "__main__":
```

```python {{ title: 'typed' }}
from robyn.types import RequestBody, QueryParams
from robyn.types import RequestBody, RequestQuery

from robyn import Robyn, OpenAPI, Request
from robyn.openapi import OpenAPIInfo, Contact, License, ExternalDocumentation, Components
Expand Down Expand Up @@ -118,7 +118,7 @@ async def welcome():
return "hi"


class GetRequestParams(QueryParams):
class GetRequestParams(RequestQuery):
appointment_id: str
year: int

Expand Down Expand Up @@ -146,7 +146,7 @@ if __name__ == "__main__":
<CodeGroup title="Subrouters">

```python {{ title: 'untyped' }}
from robyn.types import QueryParams
from robyn.types import RequestQuery

from robyn import SubRouter

Expand All @@ -159,7 +159,7 @@ async def subrouter_welcome():
return "hiiiiii subrouter"


class SubRouterGetRequestParams(QueryParams):
class SubRouterGetRequestParams(RequestQuery):
_id: int
value: str

Expand All @@ -180,7 +180,7 @@ app.include_router(subrouter)
```

```python {{ title: 'typed' }}
from robyn.types import QueryParams
from robyn.types import RequestQuery

from robyn import Request, SubRouter

Expand All @@ -193,7 +193,7 @@ async def subrouter_welcome():
return "hiiiiii subrouter"


class SubRouterGetRequestParams(QueryParams):
class SubRouterGetRequestParams(RequestQuery):
_id: int
value: str

Expand Down
18 changes: 9 additions & 9 deletions docs_src/src/pages/documentation/example_app/openapi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ python app.py --disable-openapi

## How to use?

- Query Params: The typing for query params can be added as `def get(r: Request, query_params=GetRequestParams)` where `GetRequestParams` is a subclass of `QueryParams`
- Query Params: The typing for query params can be added as `def get(r: Request, query_params=GetRequestParams)` where `GetRequestParams` is a subclass of `RequestQuery`
- Path Params are defaulted to string type (ref: https://en.wikipedia.org/wiki/Query_string)

<CodeGroup title="Basic App">

```python {{ title: 'untyped' }}
from robyn.types import RequestBody, QueryParams
from robyn.types import RequestBody, RequestQuery

from robyn import Robyn, OpenAPI
from robyn.openapi import OpenAPIInfo, Contact, License, ExternalDocumentation, Components
Expand All @@ -40,7 +40,7 @@ async def welcome():
return "hi"


class GetRequestParams(QueryParams):
class GetRequestParams(RequestQuery):
appointment_id: str
year: int

Expand All @@ -62,7 +62,7 @@ if __name__ == "__main__":
```

```python {{ title: 'typed' }}
from robyn.types import RequestBody, QueryParams
from robyn.types import RequestBody, RequestQuery

from robyn import Robyn, OpenAPI, Request
from robyn.openapi import OpenAPIInfo, Contact, License, ExternalDocumentation, Components
Expand All @@ -76,7 +76,7 @@ async def welcome():
return "hi"


class GetRequestParams(QueryParams):
class GetRequestParams(RequestQuery):
appointment_id: str
year: int

Expand Down Expand Up @@ -104,7 +104,7 @@ if __name__ == "__main__":
<CodeGroup title="Subrouters">

```python {{ title: 'untyped' }}
from robyn.types import QueryParams
from robyn.types import RequestQuery

from robyn import SubRouter

Expand All @@ -117,7 +117,7 @@ async def subrouter_welcome():
return "hiiiiii subrouter"


class SubRouterGetRequestParams(QueryParams):
class SubRouterGetRequestParams(RequestQuery):
_id: int
value: str

Expand All @@ -138,7 +138,7 @@ app.include_router(subrouter)
```

```python {{ title: 'typed' }}
from robyn.types import QueryParams
from robyn.types import RequestQuery

from robyn import Request, SubRouter

Expand All @@ -151,7 +151,7 @@ async def subrouter_welcome():
return "hiiiiii subrouter"


class SubRouterGetRequestParams(QueryParams):
class SubRouterGetRequestParams(RequestQuery):
_id: int
value: str

Expand Down

0 comments on commit d0b0a8c

Please sign in to comment.