Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ Changelog
#########


**2.2.1**
*********

OpenAPI generation fixes
========================

* fixed openapi generation for custom id type `#40 <https://github.com/mts-ai/FastAPI-JSONAPI/pull/40>`_

Authors
"""""""

* `@CosmoV`_


**2.2.0**
*********

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
# The short X.Y version.
version = "2.2"
# The full version, including alpha/beta/rc tags.
release = "2.2.0"
release = "2.2.1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion fastapi_jsonapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from fastapi_jsonapi.exceptions.json_api import HTTPException
from fastapi_jsonapi.querystring import QueryStringManager

__version__ = "2.2.0"
__version__ = "2.2.1"

__all__ = [
"init",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ packages = [

[tool.poetry]
name = "fastapi-jsonapi"
version = "2.2.0"
version = "2.2.1"
description = "FastAPI extension to create REST web api according to JSON:API specification"
authors = [
"Aleksei Nekrasov <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Config:
arbitrary_types_allowed = True


def common_handler(view: ViewBase, dto: BaseModel) -> Dict:
def common_handler(view: ViewBase, dto: SessionDependency) -> Dict:
return {"session": dto.session}


Expand Down
19 changes: 15 additions & 4 deletions tests/test_api/test_routers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict, Optional

from fastapi import APIRouter, Depends, FastAPI, Header, status
from fastapi import APIRouter, Depends, FastAPI, Header, Path, status
from httpx import AsyncClient
from pydantic import BaseModel
from pytest import mark # noqa
Expand All @@ -17,7 +17,7 @@
)
from fastapi_jsonapi.views.view_base import ViewBase
from tests.fixtures.db_connection import async_session_dependency
from tests.fixtures.views import SessionDependency, common_handler
from tests.fixtures.views import SessionDependency
from tests.misc.utils import fake
from tests.models import User
from tests.schemas import (
Expand Down Expand Up @@ -131,12 +131,23 @@ async def check_that_user_is_admin(x_auth: Annotated[str, Header()]):
class AdminOnlyPermission(BaseModel):
is_admin: Optional[bool] = Depends(check_that_user_is_admin)

def get_path_obj_id(obj_id: int = Path(default=...)):
return obj_id

class DetailGenericDependency(SessionDependency):
custom_name_obj_id: int = Depends(get_path_obj_id)

def all_handler(view: ViewBase, dto: DetailGenericDependency) -> Dict:
# test inside handler
assert dto.custom_name_obj_id == int(view.request.path_params["obj_id"])
return {"session": dto.session}

class DependencyInjectionDetailView(DetailViewBaseGeneric):
method_dependencies: Dict[HTTPMethod, HTTPMethodConfig] = {
HTTPMethod.GET: HTTPMethodConfig(dependencies=AdminOnlyPermission),
HTTPMethod.ALL: HTTPMethodConfig(
dependencies=SessionDependency,
prepare_data_layer_kwargs=common_handler,
dependencies=DetailGenericDependency,
prepare_data_layer_kwargs=all_handler,
),
}

Expand Down