Skip to content

Commit aaf4603

Browse files
Ian ZelikmanIan Zelikman
Ian Zelikman
authored and
Ian Zelikman
committed
Some fixes for lesson
1 parent bdeb45a commit aaf4603

File tree

4 files changed

+164
-32
lines changed

4 files changed

+164
-32
lines changed
+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"variables": [],
3+
"info": {
4+
"name": "OpenApi Tutorial",
5+
"_postman_id": "ad7f4d1a-fdf6-d824-9a65-37b1ec831c92",
6+
"description": "",
7+
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
8+
},
9+
"item": [
10+
{
11+
"name": "connexions_test",
12+
"description": "",
13+
"item": [
14+
{
15+
"name": "http://localhost:8080/speakers",
16+
"request": {
17+
"url": "http://localhost:8080/speakers",
18+
"method": "POST",
19+
"header": [
20+
{
21+
"key": "Content-Type",
22+
"value": "application/json",
23+
"description": ""
24+
}
25+
],
26+
"body": {
27+
"mode": "raw",
28+
"raw": "{\n \"first_name\": \"Ian\",\n \"last_name\": \"Zelikman\"\n}"
29+
},
30+
"description": ""
31+
},
32+
"response": []
33+
},
34+
{
35+
"name": "http://localhost:8080/speakers",
36+
"request": {
37+
"url": "http://localhost:8080/speakers",
38+
"method": "POST",
39+
"header": [
40+
{
41+
"key": "Content-Type",
42+
"value": "application/json",
43+
"description": ""
44+
}
45+
],
46+
"body": {
47+
"mode": "raw",
48+
"raw": "{\n \"first_name\": \"Dave\",\n \"last_name\": \"Forgac\"\n}"
49+
},
50+
"description": ""
51+
},
52+
"response": []
53+
},
54+
{
55+
"name": "http://localhost:8080/speakers",
56+
"request": {
57+
"url": "http://localhost:8080/speakers",
58+
"method": "GET",
59+
"header": [],
60+
"body": {},
61+
"description": ""
62+
},
63+
"response": []
64+
},
65+
{
66+
"name": "http://localhost:8080/talks",
67+
"request": {
68+
"url": "http://localhost:8080/talks",
69+
"method": "POST",
70+
"header": [
71+
{
72+
"key": "Content-Type",
73+
"value": "application/json",
74+
"description": ""
75+
}
76+
],
77+
"body": {
78+
"mode": "raw",
79+
"raw": "{\n\t\"title\": \"Just another API talk\",\n\t\"speaker_id\": 2,\n\t\"abstract\": \"This talk will focus on general topics on API design.\",\n\t\"duration\": 75\n}"
80+
},
81+
"description": ""
82+
},
83+
"response": []
84+
},
85+
{
86+
"name": "http://localhost:8080/talks",
87+
"request": {
88+
"url": "http://localhost:8080/talks",
89+
"method": "POST",
90+
"header": [
91+
{
92+
"key": "Content-Type",
93+
"value": "application/json",
94+
"description": ""
95+
}
96+
],
97+
"body": {
98+
"mode": "raw",
99+
"raw": "{\n\t\"title\": \"Design the API of the future\",\n\t\"speaker_id\": 2,\n\t\"abstract\": \"This talk will focus on general topics on API design in the future.\",\n\t\"duration\": 45\n}"
100+
},
101+
"description": ""
102+
},
103+
"response": []
104+
},
105+
{
106+
"name": "http://localhost:8080/talks",
107+
"request": {
108+
"url": "http://localhost:8080/talks",
109+
"method": "GET",
110+
"header": [],
111+
"body": {},
112+
"description": ""
113+
},
114+
"response": []
115+
}
116+
]
117+
}
118+
]
119+
}

lessons/lesson-2.03/example.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ parameters:
5757
name: pet-id
5858
in: path
5959
description: Pet identifier
60-
type: number
60+
type: integer
6161
required: true
6262
x-example: 42
6363

presentation/presentation.html

+21-15
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@
10511051
1. Refactor your API to use `Talk` and `Speaker` objects.
10521052
Define `Talks` and `Speakers` objects based on the previous and update the responses from
10531053
`/speakers` and `/talks` paths.
1054-
2. Add a two new paths `/speaker/{speaker-id}` and `/talk/{talk-id}`.
1054+
2. Add a two new paths `/speakers/{speaker-id}` and `/talks/{talk-id}`.
10551055
Define all the CRUD operations for them and use parameter definition outside of the action for
10561056
path parameter.
10571057

@@ -1176,7 +1176,7 @@
11761176

11771177
responses:
11781178
UnknownResponse:
1179-
description: This response is not yet docuemtned by this API.
1179+
description: This response is not yet documented by this API.
11801180
```
11811181

11821182
???
@@ -1301,7 +1301,7 @@
13011301
- Oauth security and it defines **full* Oauth **flow** in a very simple and readable way.
13021302
We even defined that we have two scopes we support which are the user and the admin.
13031303
- The second object is the security object and it sets in the global level the security for all
1304-
paths but it an be overwritten.
1304+
paths but it can be overwritten.
13051305
---
13061306

13071307
class: lesson
@@ -1434,6 +1434,8 @@
14341434
???
14351435
- tags are used in order to indicate to automatic tools of **logical groupings**
14361436
for the APIs operations.
1437+
- Here we see a tag is defined in the root level in the tags container and then used in one of the
1438+
actions.
14371439

14381440
---
14391441

@@ -1623,7 +1625,7 @@
16231625

16241626
class: center, middle, demo
16251627

1626-
# Generate Server (Flask)
1628+
# Generate Server
16271629

16281630
???
16291631

@@ -1651,7 +1653,7 @@
16511653

16521654
class: center, middle, demo
16531655

1654-
# Generate Client (Python)
1656+
# Generate Client
16551657

16561658
???
16571659
- A lot of tools generate server code for you. Here with the editor we can also generate client code.
@@ -1710,16 +1712,13 @@
17101712
???
17111713
- By using the code generator you saw how your code can be automatically generated from the spec.
17121714

1713-
- This however can't be done while you are **developing new features**. In order to keep your
1714-
contract up to date with the implementation we are using a layer on top of a Flask application
1715-
called **connexion**
1715+
- We will look at a small application similar to the the one generated from the swagger generator
1716+
and it is using a layer called connexion.
17161717

1717-
- **Connexion** defines the routing for you, and validates the input and output based on the spec.
1718-
This way you are only left with writing the implementation as you already wrote the spec so that
1719-
all should be automatic.
1718+
- **connexion** stands as a layer on top of out Python/Flask code and does the route mapping
1719+
for us from the spec into the logic.
17201720

1721-
- We will look now at the implementation of the sample application you have in your VM that was
1722-
created using this package on top of Flask.
1721+
- Connexion can also do request and responses validation for us.
17231722

17241723
---
17251724

@@ -1763,7 +1762,8 @@
17631762
- This lesson is meant to get you familiarized with the connexion app.
17641763

17651764
- Use the tool you like most to make HTTP requests. **Postman** is recommended.
1766-
If you use PyCharm/Intelij it has a similar tool as well.
1765+
1766+
- In the lesson directory you will find a postman collection you can use for the exercise.
17671767

17681768
---
17691769

@@ -1817,7 +1817,9 @@
18171817
## Usage
18181818

18191819
```
1820+
18201821
connexion run betterapis.yaml --mock=all -v
1822+
18211823
```
18221824

18231825
???
@@ -1834,10 +1836,14 @@
18341836

18351837
## Exercise Instructions
18361838

1837-
- Update all the responses to have examples
1839+
- Update responses to have examples
18381840

18391841
- Run and test your mock server
18401842

1843+
1844+
???
1845+
1846+
- Update as many responses as you would like and test your mock server.
18411847
---
18421848

18431849
class: lesson

presentation/slides.md

+23-16
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ class: lesson
939939
1. Refactor your API to use `Talk` and `Speaker` objects.
940940
Define `Talks` and `Speakers` objects based on the previous and update the responses from
941941
`/speakers` and `/talks` paths.
942-
2. Add a two new paths `/speaker/{speaker-id}` and `/talk/{talk-id}`.
942+
2. Add a two new paths `/speakers/{speaker-id}` and `/talks/{talk-id}`.
943943
Define all the CRUD operations for them and use parameter definition outside of the action for
944944
path parameter.
945945

@@ -1064,7 +1064,7 @@ class: lesson
10641064
10651065
responses:
10661066
UnknownResponse:
1067-
description: This response is not yet docuemtned by this API.
1067+
description: This response is not yet documented by this API.
10681068
```
10691069

10701070
???
@@ -1189,7 +1189,7 @@ security:
11891189
- Oauth security and it defines **full* Oauth **flow** in a very simple and readable way.
11901190
We even defined that we have two scopes we support which are the user and the admin.
11911191
- The second object is the security object and it sets in the global level the security for all
1192-
paths but it an be overwritten.
1192+
paths but it can be overwritten.
11931193
---
11941194

11951195
class: lesson
@@ -1322,6 +1322,8 @@ tags:
13221322
???
13231323
- tags are used in order to indicate to automatic tools of **logical groupings**
13241324
for the APIs operations.
1325+
- Here we see a tag is defined in the root level in the tags container and then used in one of the
1326+
actions.
13251327

13261328
---
13271329

@@ -1511,7 +1513,7 @@ class: lesson
15111513

15121514
class: center, middle, demo
15131515

1514-
# Generate Server (Flask)
1516+
# Generate Server
15151517

15161518
???
15171519

@@ -1539,7 +1541,7 @@ class: center, middle, demo
15391541

15401542
class: center, middle, demo
15411543

1542-
# Generate Client (Python)
1544+
# Generate Client
15431545

15441546
???
15451547
- A lot of tools generate server code for you. Here with the editor we can also generate client code.
@@ -1598,16 +1600,13 @@ class: lesson
15981600
???
15991601
- By using the code generator you saw how your code can be automatically generated from the spec.
16001602

1601-
- This however can't be done while you are **developing new features**. In order to keep your
1602-
contract up to date with the implementation we are using a layer on top of a Flask application
1603-
called **connexion**
1603+
- We will look at a small application similar to the the one generated from the swagger generator
1604+
and it is using a layer called connexion.
16041605

1605-
- **Connexion** defines the routing for you, and validates the input and output based on the spec.
1606-
This way you are only left with writing the implementation as you already wrote the spec so that
1607-
all should be automatic.
1606+
- **connexion** stands as a layer on top of out Python/Flask code and does the route mapping
1607+
for us from the spec into the logic.
16081608

1609-
- We will look now at the implementation of the sample application you have in your VM that was
1610-
created using this package on top of Flask.
1609+
- Connexion can also do request and responses validation for us.
16111610

16121611
---
16131612

@@ -1651,7 +1650,8 @@ class: lesson
16511650
- This lesson is meant to get you familiarized with the connexion app.
16521651

16531652
- Use the tool you like most to make HTTP requests. **Postman** is recommended.
1654-
If you use PyCharm/Intelij it has a similar tool as well.
1653+
1654+
- In the lesson directory you will find a postman collection you can use for the exercise.
16551655

16561656
---
16571657

@@ -1705,7 +1705,9 @@ class: lesson
17051705
## Usage
17061706

17071707
```
1708+
17081709
connexion run betterapis.yaml --mock=all -v
1710+
17091711
```
17101712

17111713
???
@@ -1722,10 +1724,14 @@ class: lesson
17221724

17231725
## Exercise Instructions
17241726

1725-
- Update all the responses to have examples
1727+
- Update responses to have examples
17261728

17271729
- Run and test your mock server
17281730

1731+
1732+
???
1733+
1734+
- Update as many responses as you would like and test your mock server.
17291735
---
17301736

17311737
class: lesson
@@ -1763,7 +1769,8 @@ dredd --version
17631769
the installation might be more complicated depends on your environment.
17641770
- Please also note that although it can be installed it is not supported on Windows machines.
17651771
This feature is on the road map.
1766-
- As it is written in **CoffeeScript** it is installed with npm. (TODO: It is already installed on the VMs??)
1772+
- As it is written in **CoffeeScript** it is installed with npm.
1773+
It is already installed in your VMs.
17671774
---
17681775

17691776
class: lesson

0 commit comments

Comments
 (0)