3.0 KiB
3.0 KiB
REST API specs
LoopBack API Explorer is built on top of the popular Swagger Framework. There are two components involved.
-
LoopBack builds up formal specifications of the REST APIs using the knowledge of model definitions, JavaScript method declarations, and remote mappings. The specifications are served over the following endpoints.
-
The wonderful Web UI is brought you by Swagger UI. Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation and sandbox from the REST API specifications.
Resource Listing
The first part is a listing of the REST APIs.
{
"swaggerVersion": "1.1",
"basePath": "http://localhost:3000",
"apis": [
{
"path": "/swagger/ammo"
},
{
"path": "/swagger/customers"
},
{
"path": "/swagger/inventory"
},
{
"path": "/swagger/locations"
},
{
"path": "/swagger/weapons"
}
]
}
Resource Operations
The second part describes all operations of a given model.
{
"swaggerVersion": "1.1",
"basePath": "http://localhost:3000",
"apis": [
{
"path": "/locations",
"operations": [
{
"httpMethod": "POST",
"nickname": "locations_create",
"responseClass": "object",
"parameters": [
{
"paramType": "body",
"name": "data",
"description": "Model instance data",
"dataType": "object",
"required": false,
"allowMultiple": false
}
],
"errorResponses": [],
"summary": "Create a new instance of the model and persist it into the data source",
"notes": ""
}
]
},
...
{
"path": "/locations/{id}",
"operations": [
{
"httpMethod": "GET",
"nickname": "locations_findById",
"responseClass": "any",
"parameters": [
{
"paramType": "path",
"name": "id",
"description": "Model id",
"dataType": "any",
"required": true,
"allowMultiple": false
}
],
"errorResponses": [],
"summary": "Find a model instance by id from the data source",
"notes": ""
}
]
},
...
]
}