Browse Source

Add swagger doc and build HTML from it.

feature/search
Bèr Kessels 10 months ago
parent
commit
ab17dc2923
5 changed files with 719 additions and 9 deletions
  1. 2
    1
      .gitignore
  2. 1
    0
      Makefile
  3. 78
    0
      doc/swagger.yml
  4. 1
    0
      package.json
  5. 637
    8
      yarn.lock

+ 2
- 1
.gitignore View File

@@ -5,4 +5,5 @@
5 5
 node_modules/
6 6
 
7 7
 # Ignore generated documentation
8
-doc/
8
+doc/*
9
+!doc/swagger.yml

+ 1
- 0
Makefile View File

@@ -47,3 +47,4 @@ lint:
47 47
 
48 48
 doc:
49 49
 	npx documentation build **.js -f html -o doc
50
+	npx redoc-cli bundle doc/swagger.yml --output doc/api.html

+ 78
- 0
doc/swagger.yml View File

@@ -0,0 +1,78 @@
1
+openapi: 3.0.0
2
+info: 
3
+  title: Hours RESTful API for opening hours
4
+  version: 0.0.0
5
+paths: 
6
+  /places/{id}: 
7
+    get: 
8
+      operationId: getPlaceById
9
+      parameters: 
10
+      - id: id
11
+        in: path
12
+        required: true
13
+        schema:
14
+          type: integer
15
+      responses: 
16
+        '200':
17
+          description: The Place
18
+          content:
19
+            application/json:
20
+              schema: 
21
+                $ref: '#/components/schemas/place'
22
+          links:
23
+            $ref: '#/components/links/PlaceLinks'
24
+components:
25
+  links:
26
+    PlaceLinks:
27
+      # returns array of '#/components/schemas/repository'
28
+      operationId: getPlaceById
29
+      parameters:
30
+        id: $response.body#/id
31
+  schemas: 
32
+    place: 
33
+      type: object
34
+      properties: 
35
+        id: 
36
+          type: integer
37
+        raw_opening_hours:
38
+          type: string
39
+          description: The opening hours string as found in Open Street Map
40
+        address:
41
+          type: object
42
+          properties:
43
+            street:
44
+              type: string
45
+            housenumber:
46
+              type: string
47
+            postcode:
48
+              type: string
49
+            city:
50
+              type: string
51
+            country_code:
52
+              type: string
53
+        name:
54
+          type: string
55
+          description: the name of the place, if given.
56
+        open_this_week:
57
+          type: array
58
+          items:
59
+            - properties:
60
+                from:
61
+                  type: String
62
+                  description: Datetime when this slot starts
63
+                to:
64
+                  type: String
65
+                  description: Datetime when this slot ends
66
+                unknown:
67
+                  type: boolean
68
+                  description: "true when it is not certain this slot is open."
69
+                comment:
70
+                  type: string
71
+                  description: "additional comment. Often explaining why it is unknown"
72
+        status:
73
+          type: boolean
74
+          description: "true when open now, false when closed now"
75
+        week_stable:
76
+          type: boolean
77
+          description: "true when the opening_hours will change next week(s)"
78
+

+ 1
- 0
package.json View File

@@ -19,6 +19,7 @@
19 19
     "opening_hours": "^3.5.0",
20 20
     "pg": "^7.7.1",
21 21
     "pg-hstore": "^2.3.2",
22
+    "redoc-cli": "^0.7.0",
22 23
     "sequelize": "^4.41.2",
23 24
     "sinon": "^7.1.1",
24 25
     "standard": "^12.0.1"

+ 637
- 8
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save