Skip to content

Commit

Permalink
docs(examples): adapt examples to query parameter model
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-pl authored and kevinstadler committed Dec 2, 2024
1 parent 49a892c commit ebf5e0d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
8 changes: 4 additions & 4 deletions examples/full_static_fastapi_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from typing import Annotated

from fastapi import FastAPI
from fastapi import FastAPI, Query
from pydantic import BaseModel, ConfigDict
from rdfproxy import Page, SPARQLBinding, SPARQLModelAdapter
from rdfproxy import Page, QueryParameters, SPARQLBinding, SPARQLModelAdapter


query = """
Expand Down Expand Up @@ -48,5 +48,5 @@ class Author(BaseModel):


@app.get("/")
def base_route(page: int = 1, size: int = 100) -> Page[Author]:
return adapter.query(page=page, size=size)
def base_route(query_parameters: Annotated[QueryParameters, Query()]) -> Page[Author]:
return adapter.query(query_parameters)
12 changes: 8 additions & 4 deletions examples/releven_person_fastapi_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""RDFProxy-based FastAPI route example: CRM query targeting Releven GraphDB with simple ungrouped Person model."""

from fastapi import FastAPI
from typing import Annotated

from fastapi import FastAPI, Query
from pydantic import BaseModel
from rdfproxy import Page, SPARQLModelAdapter
from rdfproxy import Page, QueryParameters, SPARQLModelAdapter


query = """
Expand Down Expand Up @@ -66,5 +68,7 @@ class R11PersonModel(BaseModel):


@app.get("/")
def base(page: int = 1, size: int = 100) -> Page[R11PersonModel]:
return adapter.query(page=page, size=size)
def base_route(
query_parameters: Annotated[QueryParameters, Query()],
) -> Page[R11PersonModel]:
return adapter.query(query_parameters)
8 changes: 4 additions & 4 deletions examples/wikidata_grouped_person_fastapi_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from typing import Annotated

from fastapi import FastAPI
from fastapi import FastAPI, Query
from pydantic import BaseModel, ConfigDict
from rdfproxy import Page, SPARQLBinding, SPARQLModelAdapter
from rdfproxy import Page, QueryParameters, SPARQLBinding, SPARQLModelAdapter


query = """
Expand Down Expand Up @@ -40,5 +40,5 @@ class Person(BaseModel):


@app.get("/")
def base(page: int = 1, size: int = 100) -> Page[Person]:
return adapter.query(page=page, size=size)
def base_route(query_parameters: Annotated[QueryParameters, Query()]) -> Page[Person]:
return adapter.query(query_parameters)
8 changes: 4 additions & 4 deletions examples/wikidata_ungrouped_person_fastapi_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from typing import Annotated

from fastapi import FastAPI
from fastapi import FastAPI, Query
from pydantic import BaseModel
from rdfproxy import Page, SPARQLBinding, SPARQLModelAdapter
from rdfproxy import Page, QueryParameters, SPARQLBinding, SPARQLModelAdapter


query = """
Expand Down Expand Up @@ -38,5 +38,5 @@ class Person(BaseModel):


@app.get("/")
def base(page: int = 1, size: int = 100) -> Page[Person]:
return adapter.query(page=page, size=size)
def base_route(query_parameters: Annotated[QueryParameters, Query()]) -> Page[Person]:
return adapter.query(query_parameters)

0 comments on commit ebf5e0d

Please sign in to comment.