@@ -20,7 +20,7 @@ revealOptions:
20
20
21
21
---
22
22
23
- 🌍 offset. earth 🌏
23
+ <!-- .slide: data-background="img/offset- earth.png" -->
24
24
25
25
---
26
26
@@ -35,6 +35,7 @@ revealOptions:
35
35
1 . Why are there no editors? <!-- .element: class="fragment" -->
36
36
1 . How/when do we create documentation? <!-- .element: class="fragment" -->
37
37
1 . How/when do we create mocks? <!-- .element: class="fragment" -->
38
+ 1 . How can we enforce style guides for docs? <!-- .element: class="fragment" -->
38
39
1 . How do we keep code and docs in sync? <!-- .element: class="fragment" -->
39
40
40
41
---
@@ -43,13 +44,11 @@ revealOptions:
43
44
44
45
---
45
46
46
- <img src =" img/logo.dark.png " style = " border : 0 ; background : transparent ; box-shadow : 0 " >
47
+ <!-- .slide: data-background ="img/workflow2.jpeg" data-background-size="contain" data- background-color="#fff" -- >
47
48
48
49
---
49
50
50
- ** Design First or Code First?**
51
-
52
- Design First <!-- .element: class="fragment" -->
51
+ <img src =" img/logo.dark.png " style =" border :0 ; background :transparent ;box-shadow :0 " >
53
52
54
53
---
55
54
@@ -61,6 +60,85 @@ https://openapi.tools <!-- .element: class="fragment" -->
61
60
62
61
---
63
62
63
+ <!-- .slide: data-background="img/tools.png" data-background-size="contain" -->
64
+
65
+ ---
66
+
67
+ ** Design First or Code First?**
68
+
69
+ ---
70
+
71
+ ``` java
72
+ class UserController {
73
+ @OpenApi (
74
+ path = " /users" ,
75
+ method = HttpMethod . POST ,
76
+ // ...
77
+ )
78
+ public static void createUser (Context ctx ) {
79
+ // ...
80
+ }
81
+ }
82
+ ```
83
+
84
+ ---
85
+
86
+ ``` php
87
+ /**
88
+ * @OA\Get(path="/2.0/users/{username}",
89
+ * operationId="getUserByName",
90
+ * @OA\Parameter(name="username",
91
+ * in="path",
92
+ * required=true,
93
+ * description=Explaining all about the username parameter
94
+ * @OA\Schema(type="string")
95
+ * ),
96
+ * @OA\Response(response="200",
97
+ * description="The User",
98
+ * @OA\JsonContent(ref="#/components/schemas/user"),
99
+ * @OA\Link(link="userRepositories", ref="#/components/links/UserRepositories")
100
+ * )
101
+ * )
102
+ */
103
+ public function getUserByName($username, $newparam)
104
+ {
105
+ }
106
+ ```
107
+
108
+ ---
109
+
110
+ > Code comments are just facts waiting to become lies.
111
+
112
+ _ <small >Vinai Kopp, A talk at #MM18IT</small >_
113
+
114
+ ---
115
+
116
+ <!-- .slide: data-background="img/code-comments.jpg" data-background-size="contain" -->
117
+
118
+ ---
119
+
120
+ <!-- .slide: data-background="img/wf-1.png" data-background-size="contain" data-background-color="#eee" -->
121
+
122
+ ---
123
+
124
+ <!-- .slide: data-background="img/wf-2.png" data-background-size="contain" data-background-color="#eee" -->
125
+
126
+ ---
127
+
128
+ <!-- .slide: data-background="img/wf-3.png" data-background-size="contain" data-background-color="#eee" -->
129
+
130
+ ---
131
+
132
+ <!-- .slide: data-background="img/lifecycle.png" data-background-size="contain" data-background-color="#eee" -->
133
+
134
+ ---
135
+
136
+ > While OpenAPI is great for describing APIs, ... ** it's definitely not a great experience to write OpenAPI documents from scratch** .
137
+
138
+ _ <small >Sebastien Armand, "Making OpenAPI Bearable With Your Own DSL"</small >_
139
+
140
+ ---
141
+
64
142
** Why are there no editors?**
65
143
66
144
https://stoplight.io/studio <!-- .element: class="fragment" -->
@@ -69,18 +147,28 @@ https://stoplight.io/studio <!-- .element: class="fragment" -->
69
147
70
148
<!-- .slide: data-background="img/studio.png" data-background-size="contain" data-background-color="#000" -->
71
149
150
+ <!-- TODO Add file system image -->
151
+
72
152
---
73
153
74
154
<!-- .slide: data-background="img/studio-adv.png" data-background-size="contain" data-background-color="#000" -->
75
155
76
156
---
77
157
158
+ <!-- .slide: data-background="img/studio-md.png" data-background-size="contain" data-background-color="#fff" -->
159
+
160
+ ---
161
+
78
162
** How/when do we create documentation?**
79
163
80
164
https://stoplight.io/docs <!-- .element: class="fragment" -->
81
165
82
166
---
83
167
168
+ <!-- .slide: data-background="img/docs.png" data-background-size="contain" data-background-color="#fff" -->
169
+
170
+ ---
171
+
84
172
** How/when do we create mocks?**
85
173
86
174
Studio has a mock server built right in 🙌 <!-- .element: class="fragment" -->
@@ -209,7 +297,7 @@ config.middleware.use Committee::Middleware::RequestValidation,
209
297
210
298
- **Ruby:** [committee](https://github.com/interagent/committee)
211
299
- **PHP:** [openapi-psr7-validator](https://github.com/lezhnev74/openapi-psr7-validator)
212
- - **NodeJS:** [fastify](https://github.com/fastify/fastify/blob/master/docs/Validation-and-Serialization.md) or [express-ajv-swagger-validation](https://github.com/Zooz/express-ajv-swagger-validation) <small><sup>Name change pending</sup></small>
300
+ - **NodeJS:** [fastify](https://github.com/fastify/fastify/blob/master/docs/Validation-and-Serialization.md) or [express-ajv-swagger-validation](https://github.com/Zooz/express-ajv-swagger-validation)
213
301
- **Python:** [connexion](https://github.com/zalando/connexion)
214
302
- **Mojolicious:** [Mojolicious](https://metacpan.org/pod/Mojolicious::Plugin::OpenAPI)
215
303
@@ -253,6 +341,19 @@ Your test suite can use the descriptions to prove the responses work properly
253
341
254
342
---
255
343
344
+ ``` rb
345
+ JsonMatchers .schema_root = " reference/example-api/models"
346
+
347
+ it ' should conform to user schema' do
348
+ get " /users/#{ subject.id } "
349
+ expect(response).to match_json_schema(' user' )
350
+ end
351
+ ```
352
+
353
+ <small >https://apisyouwonthate.com/blog/writing-documentation-via-contract-testing </small >
354
+
355
+ ---
356
+
256
357
## Request Validation at Gateway
257
358
258
359
Can't find a middleware?
@@ -357,6 +458,52 @@ validate(userSchema, { ...input, email: 123 );
357
458
358
459
---
359
460
461
+ **How can we enforce style guides for docs?**
462
+
463
+ https://stoplight.io/spectral <!-- .element: class="fragment" -->
464
+
465
+ ---
466
+
467
+ ` ` ` yaml
468
+ rules:
469
+ schema- names- pascal- case:
470
+ description: Schema names MUST be written in PascalCase
471
+ message: ' {{property}} is not PascalCase: {{error}}'
472
+ recommended: true
473
+ type: style
474
+ given: ' $.components.schemas.*~'
475
+ then:
476
+ function: pattern
477
+ functionOptions:
478
+ match: ' ^[A-Z][a-zA-Z0-9]*$'
479
+ ` ` `
480
+
481
+ ---
482
+
483
+ <!-- .slide: data-background="img/studio-spectral.png" data-background-size="contain" -->
484
+
485
+ ---
486
+
487
+ **Reference Company-Wide Style Guides**
488
+
489
+ ` ` ` yaml
490
+ extends:
491
+ - " https://api.acme.com/style-guide.yml"
492
+ ` ` `
493
+
494
+ ---
495
+
496
+ - Editor (Studio, VS Code coming...)
497
+ - CLI
498
+ - Git Hooks
499
+ - Continuous Integration
500
+
501
+ ---
502
+
503
+ Consistent APIs = ⏰ 💰 🥳
504
+
505
+ ---
506
+
360
507
<span style="font-size: 60pt">apisyouwonthate.com</span>
361
508
362
509
Join our [Slack](http://slack.apisyouwonthate.com/)
0 commit comments