Skip to content

Commit 0a3300a

Browse files
authored
Merge pull request #100 from dapper91/dev
- openapi schema generation bug fixed.
2 parents d404454 + 15f7813 commit 0a3300a

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

CHANGELOG.rst

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
1.8.2 (2023-12-07)
5+
------------------
6+
7+
- openapi schema generation bug fixed.
8+
9+
410
1.8.1 (2023-11-28)
511
------------------
612

pjrpc/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__description__ = 'Extensible JSON-RPC library'
33
__url__ = 'https://github.com/dapper91/pjrpc'
44

5-
__version__ = '1.8.1'
5+
__version__ = '1.8.2'
66

77
__author__ = 'Dmitry Pershin'
88
__email__ = '[email protected]'

pjrpc/server/specs/extractors/pydantic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def extract_result_schema(self, method: MethodType) -> Schema:
7474
description=result_schema.get('description', UNSET),
7575
deprecated=result_schema.get('deprecated', UNSET),
7676
required=required,
77-
definitions=model_schema.get('definitions', UNSET),
77+
definitions=model_schema.get('$defs', UNSET),
7878
)
7979

8080
return result_schema

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pjrpc"
3-
version = "1.8.1"
3+
version = "1.8.2"
44
description = "Extensible JSON-RPC library"
55
authors = ["Dmitry Pershin <[email protected]>"]
66
license = "Unlicense"

tests/server/resources/openapi-1.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
]
283283
},
284284
"result": {
285-
"$ref": "#/components/schemas/Model"
285+
"$ref": "#/components/schemas/ResultModel"
286286
}
287287
},
288288
"required": [
@@ -1221,6 +1221,19 @@
12211221
"field1",
12221222
"field3"
12231223
]
1224+
},
1225+
"ResultModel": {
1226+
"properties": {
1227+
"field1": {
1228+
"title": "Field1",
1229+
"type": "string"
1230+
}
1231+
},
1232+
"required": [
1233+
"field1"
1234+
],
1235+
"title": "ResultModel",
1236+
"type": "object"
12241237
}
12251238
}
12261239
},

tests/server/test_openapi.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class Model(pydantic.BaseModel):
5353
field2: Optional[int] = 1
5454
field3: SubModel
5555

56+
class ResultModel(pydantic.BaseModel):
57+
field1: str
58+
5659
class TestError(pjrpc.common.exceptions.JsonRpcError):
5760
code = 2001
5861
message = 'test error 1'
@@ -91,7 +94,7 @@ class TestError(pjrpc.common.exceptions.JsonRpcError):
9194
def method1(ctx, param1: int, param2: Model, param3) -> int:
9295
pass
9396

94-
def method2(param1: int, param2) -> Model:
97+
def method2(param1: int, param2) -> ResultModel:
9598
pass
9699

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

0 commit comments

Comments
 (0)