Skip to content

Commit 7912204

Browse files
authored
Merge pull request #41 from dapper91/dev
- openapi jsonrpc request schema fixed
2 parents b2fc556 + 852eaa2 commit 7912204

File tree

4 files changed

+61
-8
lines changed

4 files changed

+61
-8
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
5+
1.3.3 (2021-09-10)
6+
------------------
7+
8+
- openapi jsonrpc request schema fixed
9+
10+
411
1.3.2 (2021-08-30)
512
------------------
613

pjrpc/__about__.py

Lines changed: 1 addition & 1 deletion
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.3.2'
5+
__version__ = '1.3.3'
66

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

pjrpc/server/specs/openapi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,15 @@
8484
{'type': 'number'},
8585
],
8686
},
87+
'method': {
88+
'type': 'string',
89+
},
8790
'params': {
8891
'type': 'object',
8992
'properties': {},
9093
},
9194
},
92-
'required': ['jsonrpc'],
95+
'required': ['jsonrpc', 'method'],
9396
}
9497

9598
JSONRPC_HTTP_CODE = '200'
@@ -646,6 +649,7 @@ def schema(self, path: str, methods: Iterable[Method] = (), methods_map: Dict[st
646649
method_spec.update((k, v) for k, v in annotated_spec.items() if v is not UNSET)
647650

648651
request_schema = copy.deepcopy(REQUEST_SCHEMA)
652+
request_schema['properties']['method']['enum'] = [method.name]
649653

650654
for param_name, param_schema in method_spec['params_schema'].items():
651655
request_schema['properties']['params']['properties'][param_name] = param_schema.schema

tests/server/resources/openapi-1.json

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@
158158
}
159159
]
160160
},
161+
"method": {
162+
"type": "string",
163+
"enum": [
164+
"method1"
165+
]
166+
},
161167
"params": {
162168
"type": "object",
163169
"properties": {
@@ -180,7 +186,8 @@
180186
}
181187
},
182188
"required": [
183-
"jsonrpc"
189+
"jsonrpc",
190+
"method"
184191
]
185192
},
186193
"examples": {
@@ -335,6 +342,12 @@
335342
}
336343
]
337344
},
345+
"method": {
346+
"type": "string",
347+
"enum": [
348+
"method2"
349+
]
350+
},
338351
"params": {
339352
"type": "object",
340353
"properties": {
@@ -353,7 +366,8 @@
353366
}
354367
},
355368
"required": [
356-
"jsonrpc"
369+
"jsonrpc",
370+
"method"
357371
]
358372
}
359373
}
@@ -478,6 +492,12 @@
478492
}
479493
]
480494
},
495+
"method": {
496+
"type": "string",
497+
"enum": [
498+
"method3"
499+
]
500+
},
481501
"params": {
482502
"type": "object",
483503
"properties": {
@@ -494,7 +514,8 @@
494514
}
495515
},
496516
"required": [
497-
"jsonrpc"
517+
"jsonrpc",
518+
"method"
498519
]
499520
}
500521
}
@@ -617,6 +638,12 @@
617638
}
618639
]
619640
},
641+
"method": {
642+
"type": "string",
643+
"enum": [
644+
"method4"
645+
]
646+
},
620647
"params": {
621648
"type": "object",
622649
"properties": {
@@ -630,7 +657,8 @@
630657
}
631658
},
632659
"required": [
633-
"jsonrpc"
660+
"jsonrpc",
661+
"method"
634662
]
635663
}
636664
}
@@ -754,13 +782,20 @@
754782
}
755783
]
756784
},
785+
"method": {
786+
"type": "string",
787+
"enum": [
788+
"method5"
789+
]
790+
},
757791
"params": {
758792
"type": "object",
759793
"properties": {}
760794
}
761795
},
762796
"required": [
763-
"jsonrpc"
797+
"jsonrpc",
798+
"method"
764799
]
765800
}
766801
}
@@ -884,13 +919,20 @@
884919
}
885920
]
886921
},
922+
"method": {
923+
"type": "string",
924+
"enum": [
925+
"method6"
926+
]
927+
},
887928
"params": {
888929
"type": "object",
889930
"properties": {}
890931
}
891932
},
892933
"required": [
893-
"jsonrpc"
934+
"jsonrpc",
935+
"method"
894936
]
895937
}
896938
}

0 commit comments

Comments
 (0)