Skip to content

Instantly share code, notes, and snippets.

@junkor-1011
Last active December 5, 2022 13:48
Show Gist options
  • Save junkor-1011/35f264148d58ad700c3dde739f69e661 to your computer and use it in GitHub Desktop.
Save junkor-1011/35f264148d58ad700c3dde739f69e661 to your computer and use it in GitHub Desktop.
LT資料: openapiと同期したWeb API開発(fastify)
<!DOCTYPE html>
<html>
<head>
<title>openapi sync WebAPI(fastify)</title>
<meta charset="utf-8">
<style>
@page {
size: 1210px 681px;
margin: 0;
}
@media print {
.remark-slide-scaler {
width: 100% !important;
height: 100% !important;
transform: scale(1) !important;
top: 0 !important;
left: 0 !important;
}
}
body { font-family: sans-serif; }
h1, h2, h3 {
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
</head>
<body>
<textarea id="source">
class: center, middle
# Title
---
# Agenda
1. Introduction
2. Deep-dive
3. ...
---
# Introduction
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js">
</script>
<script>
var slideshow = remark.create({
sourceUrl: 'slides.md',
});
</script>
</body>
</html>

class: center, middle

OpenAPIと同期させたWeb API開発


概要

  • Web APIの実装と、仕様であるOpenAPIを同期させて開発を進められると非常に便利
    1. 実装、または仕様が先行して乖離が起こる懸念が無くなる
    2. SwaggerUIはWeb APIのテスト実行用GUIツールとしても便利
  • 選択肢が潤沢とまでは言えないので、常に出来るとは限らないのは難点
  • 代表的な例としてはPythonのマイクロWebフレームワークであるFastAPIなどがある
    • (が、今回はTypeScriptのマイクロWebフレームワークを使いたいので、fastify + fastify-swaggerを使う)

fastify

  • GitHub
  • 軽量でシンプルなマイクロWebフレームワークの部類
  • expressなども有名だが、高パフォーマンスだったり、 TypeScriptネイティブだったりする(※expressは@types/expressが必要)など後発ならではの長所も多い

fastify + swagger-ui


class: center, middle

End

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment