Skip to content

Commit

Permalink
Merge pull request #100 from dapper91/dev
Browse files Browse the repository at this point in the history
- openapi schema generation bug fixed.
  • Loading branch information
dapper91 committed Dec 7, 2023
2 parents d404454 + 15f7813 commit 0a3300a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
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

0 comments on commit 0a3300a

Please sign in to comment.