github.com/machinebox/remoto@v0.1.2-0.20191024144331-eff21a7d321f/console/README.md (about)

     1  # Remoto Console
     2  
     3  The Remote Console is an online application for writing Remoto definition files, and generating documentation, client libraries and SDKs.
     4  
     5  ## API
     6  
     7  ### Parse a definition
     8  
     9  To parse a Remoto definition file, post the source to the following endpoint:
    10  
    11  ```
    12  POST /api/define
    13  definition=...
    14  ```
    15  
    16  * `definition` field should contain the source
    17  
    18  Response will be a JSON object containing the definition or an error message if something went wrong.
    19  
    20  Unsuccessful response:
    21  
    22  ```json
    23  {
    24  	"ok": false,
    25  	"error": "io.Reader.go:24:18: expected '}', found 'EOF'"
    26  }
    27  ```
    28  
    29  Successful response:
    30  
    31  ```json
    32  {
    33  	"ok": true,
    34  	"definition": {
    35  		"services": [{
    36  			"name": "Greeter",
    37  			"comment": "Greeter is a friendly service.",
    38  			"methods": [{
    39  				"name": "Greet",
    40  				"comment": "Greet makes a greeting.",
    41  				"requestStructure": {
    42  					"name": "GreetRequest",
    43  					"comment": "GreetRequest is the request object for Greeter.Greet.",
    44  					"fields": [{
    45  						"name": "Name",
    46  						"comment": "Name is the person to greet.",
    47  						"type": {
    48  							"name": "string",
    49  							"isMultiple": false,
    50  							"isStruct": false,
    51  							"isImported": false
    52  						}
    53  					}],
    54  					"isImported": false,
    55  					"isRequestObject": true,
    56  					"isResponseObject": false
    57  				},
    58  				"responseStructure": {
    59  					"name": "GreetResponse",
    60  					"comment": "GreetResponse is the response object for Greeter.Greet.",
    61  					"fields": [{
    62  						"name": "Greeting",
    63  						"comment": "Greeting is a personalized message",
    64  						"type": {
    65  							"name": "string",
    66  							"isMultiple": false,
    67  							"isStruct": false,
    68  							"isImported": false
    69  						}
    70  					}, {
    71  						"name": "Error",
    72  						"comment": "Error is an error message if one occurred.",
    73  						"type": {
    74  							"name": "string",
    75  							"isMultiple": false,
    76  							"isStruct": false,
    77  							"isImported": false
    78  						}
    79  					}],
    80  					"isImported": false,
    81  					"isRequestObject": false,
    82  					"isResponseObject": true
    83  				}
    84  			}],
    85  			"structures": [{
    86  				"name": "GreetRequest",
    87  				"comment": "GreetRequest is the request object for Greeter.Greet.",
    88  				"fields": [{
    89  					"name": "Name",
    90  					"comment": "Name is the person to greet.",
    91  					"type": {
    92  						"name": "string",
    93  						"isMultiple": false,
    94  						"isStruct": false,
    95  						"isImported": false
    96  					}
    97  				}],
    98  				"isImported": false,
    99  				"isRequestObject": true,
   100  				"isResponseObject": false
   101  			}, {
   102  				"name": "GreetResponse",
   103  				"comment": "GreetResponse is the response object for Greeter.Greet.",
   104  				"fields": [{
   105  					"name": "Greeting",
   106  					"comment": "Greeting is a personalized message",
   107  					"type": {
   108  						"name": "string",
   109  						"isMultiple": false,
   110  						"isStruct": false,
   111  						"isImported": false
   112  					}
   113  				}, {
   114  					"name": "Error",
   115  					"comment": "Error is an error message if one occurred.",
   116  					"type": {
   117  						"name": "string",
   118  						"isMultiple": false,
   119  						"isStruct": false,
   120  						"isImported": false
   121  					}
   122  				}],
   123  				"isImported": false,
   124  				"isRequestObject": false,
   125  				"isResponseObject": true
   126  			}]
   127  		}],
   128  		"packageName": "remoto",
   129  		"packageComment": "Remoto service is an example service."
   130  	}
   131  }
   132  ```
   133  
   134  ### Get templates
   135  
   136  Get a list of templates:
   137  
   138  ```
   139  GET /api/templates
   140  ```
   141  
   142  Returns:
   143  
   144  ```json
   145  {
   146  	"templates": [{
   147  		"name": "html/docs.bootstrap.html",
   148  		"x": false,
   149  		"dirs": ["html"],
   150  		"label": "docs.bootstrap.html"
   151  	}, {
   152  		"name": "remotohttp/client.es6.js",
   153  		"x": false,
   154  		"dirs": ["remotohttp"],
   155  		"label": "client.es6.js"
   156  	}, {
   157  		"name": "remotohttp/client.go",
   158  		"x": false,
   159  		"dirs": ["remotohttp"],
   160  		"label": "client.go"
   161  	}, {
   162  		"name": "remotohttp/client.jquery.js",
   163  		"x": false,
   164  		"dirs": ["remotohttp"],
   165  		"label": "client.jquery.js"
   166  	}, {
   167  		"name": "remotohttp/server.go",
   168  		"x": false,
   169  		"dirs": ["remotohttp"],
   170  		"label": "server.go"
   171  	}, {
   172  		"name": "x/go/cli/cobra-cli.go",
   173  		"x": true,
   174  		"dirs": ["x", "go", "cli"],
   175  		"label": "cobra-cli.go"
   176  	}]
   177  }
   178  ```
   179  
   180  ## Generate code from a template
   181  
   182  ```
   183  POST /api/templates/{name}
   184  definition=<remoto defintion>
   185  ```
   186  
   187  * `{name}` - (string) The template name (looks like a path) to use to generate code
   188  * `definition` - (string) The Remoto definition file to use to generaate the template
   189  
   190  ## Generare all code
   191  
   192  You can use the helpful shortcut to generate a `.zip` file containing all generated code:
   193  
   194  ```
   195  POST /api/all.zip
   196  definition=<remoto defintion>
   197  ```
   198  
   199  * `definition` - (string) The Remoto definition file to use to generaate the template
   200  
   201  Downloads a ZIP file containing all generated code.