Created
December 4, 2018 17:33
-
-
Save thephez/c6b46572c950593f7704f71442a6c733 to your computer and use it in GitHub Desktop.
Example of describing JSON-RPC 2.0 API with OpenAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"x-send-defaults": true, | |
"openapi": "3.0.0", | |
"x-api-id": "json-rpc-example", | |
"info": { | |
"title": "JSON-RPC OpenAPI", | |
"version": "1.0.0", | |
"description": "Example of how to describe a JSON-RPC 2 API in OpenAPI" | |
}, | |
"servers": [ | |
{ | |
"url": "http://127.0.0.1:3000" | |
} | |
], | |
"paths": { | |
"/examplePost": { | |
"post": { | |
"operationId": "examplePost", | |
"deprecated": false, | |
"summary": "Example of JSON-RPC2 Post", | |
"description": "Example post using JSON-RPC params.", | |
"tags": [ | |
"JSONRPC" | |
], | |
"parameters": [], | |
"responses": { | |
"200": { | |
"description": "Successful response" | |
} | |
}, | |
"requestBody": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"required": [ | |
"method", | |
"id", | |
"jsonrpc", | |
"params" | |
], | |
"properties": { | |
"method": { | |
"type": "string", | |
"default": "examplePost", | |
"description": "Method name" | |
}, | |
"id": { | |
"type": "integer", | |
"default": 1, | |
"format": "int32", | |
"description": "Request ID" | |
}, | |
"jsonrpc": { | |
"type": "string", | |
"default": "2.0", | |
"description": "JSON-RPC Version (2.0)" | |
}, | |
"params": { | |
"title": "Parameters", | |
"type": "object", | |
"required": [ | |
"jsonParam" | |
], | |
"properties": { | |
"jsonParam": { | |
"type": "integer", | |
"default": 1, | |
"description": "A param to include" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"/examplePost2": { | |
"post": { | |
"operationId": "examplePost2", | |
"deprecated": false, | |
"summary": "Example of JSON-RPC2 Post", | |
"description": "Example post using JSON-RPC params.", | |
"tags": [ | |
"JSONRPC" | |
], | |
"parameters": [], | |
"responses": { | |
"200": { | |
"description": "Successful response" | |
} | |
}, | |
"requestBody": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/examplePost" | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"x-headers": [], | |
"x-explorer-enabled": true, | |
"x-proxy-enabled": true, | |
"x-samples-enabled": true, | |
"x-samples-languages": [ | |
"curl", | |
"node", | |
"ruby", | |
"javascript", | |
"python" | |
], | |
"components": { | |
"schemas": { | |
"JsonRpcRequired": { | |
"type": "object", | |
"required": [ | |
"method", | |
"id", | |
"jsonrpc" | |
], | |
"properties": { | |
"method": { | |
"type": "string", | |
"default": "examplePost", | |
"description": "Method name" | |
}, | |
"id": { | |
"type": "integer", | |
"default": 1, | |
"format": "int32", | |
"description": "Request ID" | |
}, | |
"jsonrpc": { | |
"type": "string", | |
"default": "2.0", | |
"description": "JSON-RPC Version (2.0)" | |
} | |
}, | |
"discriminator": { | |
"propertyName": "method_name" | |
} | |
}, | |
"examplePost": { | |
"allOf": [ | |
{ | |
"$ref": "#/components/schemas/JsonRpcRequired" | |
}, | |
{ | |
"type": "object", | |
"properties": { | |
"params": { | |
"title": "Parameters", | |
"type": "object", | |
"required": [ | |
"jsonParam" | |
], | |
"properties": { | |
"jsonParam": { | |
"type": "integer", | |
"default": 1, | |
"description": "A param to include" | |
} | |
} | |
} | |
} | |
} | |
] | |
} | |
} | |
}, | |
"tags": [] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment