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

Dev #100

Merged
merged 3 commits into from
Dec 7, 2023
Merged

Dev #100

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
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

1.8.2 (2023-12-07)
------------------

- openapi schema generation bug fixed.


1.8.1 (2023-11-28)
------------------

Expand Down
2 changes: 1 addition & 1 deletion pjrpc/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__description__ = 'Extensible JSON-RPC library'
__url__ = 'https://github.com/dapper91/pjrpc'

__version__ = '1.8.1'
__version__ = '1.8.2'

__author__ = 'Dmitry Pershin'
__email__ = 'dapper1291@gmail.com'
Expand Down
2 changes: 1 addition & 1 deletion pjrpc/server/specs/extractors/pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def extract_result_schema(self, method: MethodType) -> Schema:
description=result_schema.get('description', UNSET),
deprecated=result_schema.get('deprecated', UNSET),
required=required,
definitions=model_schema.get('definitions', UNSET),
definitions=model_schema.get('$defs', UNSET),
)

return result_schema
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pjrpc"
version = "1.8.1"
version = "1.8.2"
description = "Extensible JSON-RPC library"
authors = ["Dmitry Pershin <dapper1291@gmail.com>"]
license = "Unlicense"
Expand Down
15 changes: 14 additions & 1 deletion tests/server/resources/openapi-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
]
},
"result": {
"$ref": "#/components/schemas/Model"
"$ref": "#/components/schemas/ResultModel"
}
},
"required": [
Expand Down Expand Up @@ -1221,6 +1221,19 @@
"field1",
"field3"
]
},
"ResultModel": {
"properties": {
"field1": {
"title": "Field1",
"type": "string"
}
},
"required": [
"field1"
],
"title": "ResultModel",
"type": "object"
}
}
},
Expand Down
5 changes: 4 additions & 1 deletion tests/server/test_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Model(pydantic.BaseModel):
field2: Optional[int] = 1
field3: SubModel

class ResultModel(pydantic.BaseModel):
field1: str

class TestError(pjrpc.common.exceptions.JsonRpcError):
code = 2001
message = 'test error 1'
Expand Down Expand Up @@ -91,7 +94,7 @@ class TestError(pjrpc.common.exceptions.JsonRpcError):
def method1(ctx, param1: int, param2: Model, param3) -> int:
pass

def method2(param1: int, param2) -> Model:
def method2(param1: int, param2) -> ResultModel:
pass

def method3(param1: Optional[float] = None, param2: int = 1) -> Optional[str]:
Expand Down
Loading