|
8 | 8 |
|
9 | 9 | 00:00:12 Now what?
|
10 | 10 |
|
11 |
| -00:00:13 That's the conversation I dive into over the next hour with Stanislav Samiv. |
| 11 | +00:00:13 That's the conversation I dive into over the next hour with Stanislav Zmiev |
12 | 12 |
|
13 | 13 | 00:00:17 We're talking about versioning APIs on this, the 450th episode of Talk Python to Me,
|
14 | 14 |
|
|
214 | 214 |
|
215 | 215 | 00:06:46 But then my other projects, the ones that I maintain, are way cooler.
|
216 | 216 |
|
217 |
| -00:06:50 For example, Bidentic Duality enables you to have multiple versions of your Bidentic models |
| 217 | +00:06:50 For example, Pydantic Duality enables you to have multiple versions of your Pydantic models |
218 | 218 |
|
219 | 219 | 00:06:57 for almost free in terms of performance and without any code generation.
|
220 | 220 |
|
221 |
| -00:07:02 And CADWIN, the project we're going to be discussing today, implements, I guess, the fullest |
| 221 | +00:07:02 And CADWYN, the project we're going to be discussing today, implements, I guess, the fullest |
222 | 222 |
|
223 | 223 | 00:07:08 and most sophisticated API versioning paradigm there is at this point.
|
224 | 224 |
|
225 | 225 | 00:07:12 - Excellent, yeah.
|
226 | 226 |
|
227 |
| -00:07:13 - A lot of cool stuff. - Bidentic Duality looks, yeah, Bidentic Duality looks really, really cool. |
| 227 | +00:07:13 - A lot of cool stuff. - Pydantic Duality looks, yeah, Pydantic Duality looks really, really cool. |
228 | 228 |
|
229 | 229 | 00:07:17 So a lot of neat stuff here.
|
230 | 230 |
|
231 | 231 | 00:07:19 A lot of different ways people might know about you.
|
232 | 232 |
|
233 |
| -00:07:21 So yeah, CADWIN's the one we're gonna be focusing on for here. |
| 233 | +00:07:21 So yeah, CADWYN's the one we're gonna be focusing on for here. |
234 | 234 |
|
235 | 235 | 00:07:25 So let's start with talking about APIs.
|
236 | 236 |
|
|
668 | 668 |
|
669 | 669 | 00:21:20 Visit talkpython.fm/neo4j to get started.
|
670 | 670 |
|
671 |
| -00:21:25 That's talkpython.fm/neo, the number four, and the letter J. |
| 671 | +00:21:25 That's talkpython.fm/neo4j, the number four, and the letter J. |
672 | 672 |
|
673 | 673 | 00:21:30 Thank you to Neo4j for supporting Talk Python to Me.
|
674 | 674 |
|
|
1208 | 1208 |
|
1209 | 1209 | 00:38:34 who just wanna learn how to do API versioning, but failed to find any resources.
|
1210 | 1210 |
|
1211 |
| -00:38:39 So Katwin also becomes this, I guess, hub for API versioning resources and anything related to them. |
| 1211 | +00:38:39 So Cadwyn also becomes this, I guess, hub for API versioning resources and anything related to them. |
1212 | 1212 |
|
1213 | 1213 | 00:38:46 - It seems like it would probably be pretty easy to adapt to anything that uses Pydantic
|
1214 | 1214 |
|
|
1276 | 1276 |
|
1277 | 1277 | 00:40:53 So some good questions, but I think they'll be somewhat answered if we just maybe talk us through your tutorial here.
|
1278 | 1278 |
|
1279 |
| -00:41:02 Like how do we use Kadwin and how does it manifest? |
| 1279 | +00:41:02 Like how do we use Cadwyn and how does it manifest? |
1280 | 1280 |
|
1281 | 1281 | 00:41:06 How does it work at runtime?
|
1282 | 1282 |
|
1283 | 1283 | 00:41:07 Stuff like that.
|
1284 | 1284 |
|
1285 |
| -00:41:08 - First, before using Kadwin, you know, you write your regular app, but then you just structure it a little bit differently. |
| 1285 | +00:41:08 - First, before using Cadwyn, you know, you write your regular app, but then you just structure it a little bit differently. |
1286 | 1286 |
|
1287 | 1287 | 00:41:13 When you are versioning, you need a directory that you will consider versioned.
|
1288 | 1288 |
|
|
1314 | 1314 |
|
1315 | 1315 | 00:42:13 The, if you take a look, we have a versioned API router.
|
1316 | 1316 |
|
1317 |
| -00:42:17 Then you use the Kadwin versioned app. |
| 1317 | +00:42:17 Then you use the Cadwyn versioned app. |
1318 | 1318 |
|
1319 | 1319 | 00:42:20 You generate version routers, and then it's going to generate a really nice swagger for them.
|
1320 | 1320 |
|
|
1336 | 1336 |
|
1337 | 1337 | 00:42:55 field addresses didn't exist.
|
1338 | 1338 |
|
1339 |
| -00:42:57 - You have a user object, which is a pedantic model. |
| 1339 | +00:42:57 - You have a user object, which is a pydantic model. |
1340 | 1340 |
|
1341 | 1341 | 00:43:00 The user object in version, the initial version, just had a field called address, which was a string.
|
1342 | 1342 |
|
|
1354 | 1354 |
|
1355 | 1355 | 00:43:30 - You simply describe how do you migrate your schemas?
|
1356 | 1356 |
|
1357 |
| -00:43:32 How do you change your schema classes, your pedantic models? |
| 1357 | +00:43:32 How do you change your schema classes, your pydantic models? |
1358 | 1358 |
|
1359 | 1359 | 00:43:36 And then you describe how you convert your requests and response, and that's it.
|
1360 | 1360 |
|
|
1454 | 1454 |
|
1455 | 1455 | 00:46:36 Is it passed as a, is the version passed as a header, it's a query string, part of the URL?
|
1456 | 1456 |
|
1457 |
| -00:46:41 - The version is passed as a header and Cadwin by default requires it to be. |
| 1457 | +00:46:41 - The version is passed as a header and Cadwyn by default requires it to be. |
1458 | 1458 |
|
1459 | 1459 | 00:46:47 But if you have some developer portal, if you want to store your version in some database,
|
1460 | 1460 |
|
|
1524 | 1524 |
|
1525 | 1525 | 00:48:57 And then at some point, use this core to build more Kadwins, you know?
|
1526 | 1526 |
|
1527 |
| -00:49:01 Kadwin Django, Kadwin Flask, whatever. |
| 1527 | +00:49:01 Cadwyn Django, Kadwin Flask, whatever. |
1528 | 1528 |
|
1529 | 1529 | 00:49:03 Or it doesn't even have to be a part of Kadwin.
|
1530 | 1530 |
|
|
1576 | 1576 |
|
1577 | 1577 | 00:50:52 but they still, most of the time, work with untyped code, which essentially can lead to many errors.
|
1578 | 1578 |
|
1579 |
| -00:50:57 Kadwin tries to make sure that you still work with your schemas, you still know which schema you work with, |
| 1579 | +00:50:57 Cadwyn tries to make sure that you still work with your schemas, you still know which schema you work with, |
1580 | 1580 |
|
1581 | 1581 | 00:51:03 it's always the latest.
|
1582 | 1582 |
|
1583 |
| -00:51:05 And Kadwin tries to make sure that you're not going to have any type errors |
| 1583 | +00:51:05 And Cadwyn tries to make sure that you're not going to have any type errors |
1584 | 1584 |
|
1585 | 1585 | 00:51:11 if you don't want to, and you're going to have all of the niceties of having this dynamic request response conversion thing.
|
1586 | 1586 |
|
|
1678 | 1678 |
|
1679 | 1679 | 00:54:08 It's an amazing library and you don't need anything else.
|
1680 | 1680 |
|
1681 |
| -00:54:12 CADWIN is for use cases where you need to keep a larger number of versions, |
| 1681 | +00:54:12 CADWYN is for use cases where you need to keep a larger number of versions, |
1682 | 1682 |
|
1683 | 1683 | 00:54:18 or if the changes between your versions are much trickier.
|
1684 | 1684 |
|
|
1780 | 1780 |
|
1781 | 1781 | 00:56:33 And it remains unchanged basically, right?
|
1782 | 1782 |
|
1783 |
| -00:56:35 - Kadwin tries to escape this kind of verbosity. |
| 1783 | +00:56:35 - Cadwyn tries to escape this kind of verbosity. |
1784 | 1784 |
|
1785 | 1785 | 00:56:39 And essentially you have all endpoints everywhere.
|
1786 | 1786 |
|
|
1834 | 1834 |
|
1835 | 1835 | 00:57:44 You know, before we wrap it up, two quick things, you know, notable PyPI package.
|
1836 | 1836 |
|
1837 |
| -00:57:49 I mean, we've already given Kadwin a shout out. |
| 1837 | +00:57:49 I mean, we've already given Cadwyn a shout out. |
1838 | 1838 |
|
1839 | 1839 | 00:57:51 Anything else that like, oh, I came across this and it was super cool.
|
1840 | 1840 |
|
|
1844 | 1844 |
|
1845 | 1845 | 00:57:59 - For us in our company, we started using one more package of mine.
|
1846 | 1846 |
|
1847 |
| -00:58:04 It's called ByteTest fixture classes. |
| 1847 | +00:58:04 It's called PyTest fixture classes. |
1848 | 1848 |
|
1849 | 1849 | 00:58:06 - Okay. - Essentially, when you are building groups of fixtures that create some objects for you,
|
1850 | 1850 |
|
|
1854 | 1854 |
|
1855 | 1855 | 00:58:21 - Yeah.
|
1856 | 1856 |
|
1857 |
| -00:58:22 - A factory fixture pattern that you can see in ByteTest allows you to, you know, make a function within a function |
| 1857 | +00:58:22 - A factory fixture pattern that you can see in PyTest allows you to, you know, make a function within a function |
1858 | 1858 |
|
1859 | 1859 | 00:58:29 and one of them is a fixture and that's all cool and nice, but then it's not typed.
|
1860 | 1860 |
|
|
1864 | 1864 |
|
1865 | 1865 | 00:58:41 And otherwise you can write a protocol and it's a lot of code.
|
1866 | 1866 |
|
1867 |
| -00:58:45 What ByteTest fixture classes does is it allows you to type everything there. |
| 1867 | +00:58:45 What PyTest fixture classes does is it allows you to type everything there. |
1868 | 1868 |
|
1869 | 1869 | 00:58:50 So you write the same amount of code, but it's all typed and now you have,
|
1870 | 1870 |
|
|
1896 | 1896 |
|
1897 | 1897 | 00:59:36 only for your internal microservices or only for your front end, then consider using the simple tools.
|
1898 | 1898 |
|
1899 |
| -00:59:44 Consider using the FastAPI versioning, you know, Flask, Raybar, things like that. |
| 1899 | +00:59:44 Consider using the FastAPI versioning, you know, Flask, Rebar, things like that. |
1900 | 1900 |
|
1901 | 1901 | 00:59:49 But then once you realize that you need to support versions for months and you need three or more versions
|
1902 | 1902 |
|
1903 | 1903 | 00:59:56 and you're providing your versions as a public, you know, to the public,
|
1904 | 1904 |
|
1905 |
| -01:00:01 then I advise moving straight into CADWIN or CADWIN-like frameworks. |
| 1905 | +01:00:01 then I advise moving straight into CADWYN or CADWYN-like frameworks. |
1906 | 1906 |
|
1907 |
| -01:00:06 If you use FastAPI, you can just use CADWIN. |
| 1907 | +01:00:06 If you use FastAPI, you can just use CADWYN. |
1908 | 1908 |
|
1909 | 1909 | 01:00:08 It has a bit of a learning curve, but within making one version, you will realize just how simple it is.
|
1910 | 1910 |
|
1911 |
| -01:00:14 And if you're not using CADWIN, that's fine as well. |
| 1911 | +01:00:14 And if you're not using CADWYN, that's fine as well. |
1912 | 1912 |
|
1913 | 1913 | 01:00:17 I have all of the resources that I used to build it and all of the resources, you know,
|
1914 | 1914 |
|
|
1995 | 1995 | 01:02:25 (upbeat music)
|
1996 | 1996 |
|
1997 | 1997 | 01:02:43 Thank you for watching.
|
1998 |
| - |
0 commit comments