Skip to content

Commit

Permalink
Merge pull request #41 from dapper91/dev
Browse files Browse the repository at this point in the history
- openapi jsonrpc request schema fixed
  • Loading branch information
dapper91 authored Sep 10, 2021
2 parents b2fc556 + 852eaa2 commit 7912204
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========


1.3.3 (2021-09-10)
------------------

- openapi jsonrpc request schema fixed


1.3.2 (2021-08-30)
------------------

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.3.2'
__version__ = '1.3.3'

__author__ = 'Dmitry Pershin'
__email__ = '[email protected]'
Expand Down
6 changes: 5 additions & 1 deletion pjrpc/server/specs/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@
{'type': 'number'},
],
},
'method': {
'type': 'string',
},
'params': {
'type': 'object',
'properties': {},
},
},
'required': ['jsonrpc'],
'required': ['jsonrpc', 'method'],
}

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

request_schema = copy.deepcopy(REQUEST_SCHEMA)
request_schema['properties']['method']['enum'] = [method.name]

for param_name, param_schema in method_spec['params_schema'].items():
request_schema['properties']['params']['properties'][param_name] = param_schema.schema
Expand Down
54 changes: 48 additions & 6 deletions tests/server/resources/openapi-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@
}
]
},
"method": {
"type": "string",
"enum": [
"method1"
]
},
"params": {
"type": "object",
"properties": {
Expand All @@ -180,7 +186,8 @@
}
},
"required": [
"jsonrpc"
"jsonrpc",
"method"
]
},
"examples": {
Expand Down Expand Up @@ -335,6 +342,12 @@
}
]
},
"method": {
"type": "string",
"enum": [
"method2"
]
},
"params": {
"type": "object",
"properties": {
Expand All @@ -353,7 +366,8 @@
}
},
"required": [
"jsonrpc"
"jsonrpc",
"method"
]
}
}
Expand Down Expand Up @@ -478,6 +492,12 @@
}
]
},
"method": {
"type": "string",
"enum": [
"method3"
]
},
"params": {
"type": "object",
"properties": {
Expand All @@ -494,7 +514,8 @@
}
},
"required": [
"jsonrpc"
"jsonrpc",
"method"
]
}
}
Expand Down Expand Up @@ -617,6 +638,12 @@
}
]
},
"method": {
"type": "string",
"enum": [
"method4"
]
},
"params": {
"type": "object",
"properties": {
Expand All @@ -630,7 +657,8 @@
}
},
"required": [
"jsonrpc"
"jsonrpc",
"method"
]
}
}
Expand Down Expand Up @@ -754,13 +782,20 @@
}
]
},
"method": {
"type": "string",
"enum": [
"method5"
]
},
"params": {
"type": "object",
"properties": {}
}
},
"required": [
"jsonrpc"
"jsonrpc",
"method"
]
}
}
Expand Down Expand Up @@ -884,13 +919,20 @@
}
]
},
"method": {
"type": "string",
"enum": [
"method6"
]
},
"params": {
"type": "object",
"properties": {}
}
},
"required": [
"jsonrpc"
"jsonrpc",
"method"
]
}
}
Expand Down

0 comments on commit 7912204

Please sign in to comment.