Blame view

node_modules/loopback/docs/api-explorer-details.md 2.97 KB
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  <!-- NOTE: This file is not currently included into the docs.  Need to (a) decide if this info is important and if so (b) decide where to put it.
  
  -->
  
  # REST API specs
  
  LoopBack API Explorer is built on top of the popular
  [Swagger Framework](https://github.com/wordnik/swagger-core/wiki). There are two
  components involved.
  
  1. 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.
  
  2. The wonderful Web UI is brought you by [Swagger UI](https://github.com/strongloop/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.
  
  - http://localhost:3000/swagger/resources
  
  ```javascript
      {
        "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.
  
  - http://localhost:3000/swagger/locations
  
  ```javascript
      {
        "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": ""
              }
            ]
          },
          ...
        ]
      }
  ```