Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Compiler APIを利用して TypeScriptのAPI型定義ファイルからOpenAP...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Musashi Tsunoda
May 08, 2024
Technology
14
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Compiler APIを利用して TypeScriptのAPI型定義ファイルからOpenAPI.jsonを作成する/Create OpenAPI.json from a TypeScript API type definition file using the Compiler API
Musashi Tsunoda
May 08, 2024
More Decks by Musashi Tsunoda
See All by Musashi Tsunoda
How I Stopped Using an External Monitor
kakudenbuzo
1
69
Other Decks in Technology
See All in Technology
スタートアップにAmazon EKSは早すぎる? マルチプロダクト戦略を加速する Platform Engineeringの実践 / Is Amazon EKS Too Soon for Startups? Practical Platform Engineering to Accelerate a Multi-Product Strategy
elmodev09
1
1.7k
AI時代のコスト管理を考えよう〜明日から使える実践AWSノウハウ~
yoshimi0227
0
830
AIが自律的に回る開発ループを設計してチーム開発に組み込む
nekorush14
0
120
作る力から、見極める力へ — AI時代に広がるエンジニアの価値と役割
rince
0
310
起点・思考・出力で分解する 〜PM業務の自動化設計〜
kazu_kichi_67
1
950
FPGAの開発コンペでZephyrを使ってみた
iotengineer22
0
190
インシデントレスポンス演習 I / Incident Response Exercise I
ks91
PRO
0
110
Lightning近況報告
kozy4324
0
220
Claude Codeをどのように キャッチアップしているか
oikon48
13
8.8k
新しいUbuntu/GNOMEが使いたいからXからWaylandへ移行頑張ってるの巻 2026-06-20
nobutomurata
0
160
WebGIS AI Agentの紹介
_shimizu
0
530
複数のSONiCディストリビューションを触りながら比較してみた
sonic
0
120
Featured
See All Featured
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
360
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
630
RailsConf 2023
tenderlove
30
1.5k
Context Engineering - Making Every Token Count
addyosmani
9
980
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
270
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
170
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
400
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
850
Transcript
Compiler APIΛར༻ͯ͠ APIܕఆٛϑΝΠϧ͔Β OpenAPI.jsonΛ࡞͢Δ TypeScript Developers Meetup ʙϑϩϯτ͔ΒόοΫ·Ͱ TSʙ
2024/05/08
AGENDA 1. ࣗݾհ 2. Communeͷٕज़ελοΫ 3. Communeʹ͓͚ΔAPIͷܕఆٛ 4. ࠷ۙͷ՝ 5.
APIܕఆٛϑΝΠϧ͔ΒOpenAPI.jsonΛ࡞ 6. ࠓޙͷ՝ 7. ·ͱΊ
© Commune Inc. All rights reserved ֯ాଂ (a.k.a. Buzo) Tech
& Platform Software engineer Musashi Tsunoda ڈͷ8݄ʹίϛϡʔϯגࣜձࣾʹೖࣾɻ TypeScriptʹΑΔόοΫΤϯυɾϑϩϯτΤϯυ྆ ํͷ։ൃΛߦ͏ɻ ུ֓ SNS X: @buzou_muzou ࣗݾհ ͖ͳ͜ͱ ݸਓ։ൃͱϘΫγϯά
Communeͷٕज़ελοΫ
© Commune Inc. All rights reserved Communeͷٕज़ελοΫ όοΫΤϯυ ϞόΠϧΞϓϦ ϑϩϯτΤϯυ
© Commune Inc. All rights reserved • WebTypeScriptͰ౷Ұ ◦ ֶशίετ͕͍
◦ ࠾༻ͷ໘ͰͷΤϯδχΞͷ֬อͷ༏Ґੑ ◦ ܕఆٛϑΝΠϧͷڞ༗ʹΑΔ։ൃͷޮԽ • ϞόΠϧFlutter ◦ ΫϩεϓϥοτϑΥʔϜͳ։ൃ Communeͷٕज़ελοΫ
Communeʹ͓͚Δ APIͷܕఆٛ
© Commune Inc. All rights reserved όοΫΤϯυɾϑϩϯτΤϯυͰAPIͷܕఆٛͷڞ༗ Communeʹ͓͚ΔAPIͷܕఆٛ
࠷ۙͷ՝
© Commune Inc. All rights reserved • APIͷฦ٫ͷϥϯλΠϜͰͷܕͷෆҰக ◦ booleanͷ͕ͣ
0 or 1ʹͳ͍ͬͯΔ ◦ numberͷ͕ͣstringʹͳ͍ͬͯΔ ◦ etc • ϞόΠϧνʔϜͱͷ࿈ܞ ◦ APIΤϯυϙΠϯτͷ ৽ن࡞ɾ༷มߋ࣌ͷೝࣝͣΕ ࠷ۙͷ՝
OpenAPI.jsonΛ࡞Ζ͏
© Commune Inc. All rights reserved • Compiler APIͰAPIܕఆ͔ٛΒOpenAPI.jsonΛ࡞͢Δ ◦
εΩʔϚۦಈͷAPI։ൃʹγϑτ ◦ ϞόΠϧνʔϜͱͷ࿈ܞʹ༻ • OpenAPI.jsonΛݩʹೖग़ྗͷܕνΣοΫΛಋೖ ◦ ϥϯλΠϜͷϦΫΤετͱϨεϙϯεͷܕΛอূ ํ
Compiler APIͱ
© Commune Inc. All rights reserved Compilier APIͱ • TypeScriptͷτϥϯεύΠϧ࣌ʹߦ͍ͬͯΔΑ͏ͳॲཧΛ
ݺͼग़͢͜ͱ͕Ͱ͖ΔAPI • ίʔυΛநߏจ(AST)ͱͯ͠ղੳ͕Ͱ͖Δ • ίʔυͷมࣗಈੜͳͲʹར༻͢Δ͜ͱ͕Ͱ͖Δ • Web APIͰͳ͍ • TypeScriptͷ։ൃݩ͕ެ։͍ͯ͠Δ https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API
Compiler APIΛͬͯ OpenAPI.jsonΛ࡞͢Δ
© Commune Inc. All rights reserved ΰʔϧ: APIܕఆٛϑΝΠϧ͔ΒOpenAPI.jsonΛ࡞ OpenAPI.jsonΛ࡞
© Commune Inc. All rights reserved OpenAPI.jsonΛ࡞ Tsunagger *ʮͭͳ͙ +
Swaggerʯ͔Β໋໊ *Tsunoda(ࢲͷ໊લ)ͱҰؔͳ͍ OpenAPI.json͕ੜͰ͖ΔεΫϦϓτΛ࡞ npm run tsunagger Ͱ
© Commune Inc. All rights reserved OpenAPI.jsonΛ࡞ CommuneͷAPIܕఆٛϑΝΠϧ • Type͕HTTPϝιου໊
◦ ΤϯυϙΠϯτύε໊ ▪ ϦΫΤετͷܕఆٛ ▪ Ϩεϙϯεͷܕఆٛ
© Commune Inc. All rights reserved OpenAPI.jsonΛ࡞ • ΤϯυϙΠϯτͷύε໊͝ͱ ◦
HTTPϝιου໊ ▪ ϦΫΤετͷܕఆٛ ▪ Ϩεϙϯεͷܕఆٛ OpenAPIʹΑΔAPIεΩʔϚఆٛ
© Commune Inc. All rights reserved OpenAPI.jsonΛ࡞ foo: string “foo”:
{“type”:”string”}, bar: number “bar”: {“type”:“number”} baz: { foo: string, bar: number } “baz”: { “type”: “object”, "properties": { “foo”: {“type”:”string”}, “bar”: {“type”:“number”} } } TypeScript OpenAPI.json
© Commune Inc. All rights reserved OpenAPI.jsonΛ࡞ Compiler APIΛۦͯ͠ɺ TSͷநߏจ͔ΒܕఆٛΛղੳ͍ͯ͘͠
© Commune Inc. All rights reserved OpenAPI.jsonΛ࡞ https://ts-ast-viewer.com/
© Commune Inc. All rights reserved 1. TSϑΝΠϧͷಡΈࠐΈ 2. ts.SourceFileϑΝΠϧΦϒδΣΫτͷੜ
3. ֤ϊʔυͰܕͷγϯϘϧΛऔಘ a. ObjectArrayܕͷ߹ ͞ΒʹͦͷࢠϊʔυͷܕͷγϯϘϧΛऔಘ 4. OpenAPI.jsonͷܗࣜʹͯ͠ϑΝΠϧʹग़ྗ OpenAPI.jsonΛ࡞ TsunaggerͷॲཧͷྲྀΕ
© Commune Inc. All rights reserved OpenAPI.jsonΛ࡞ OpenAPI.jsonͷ࡞ͷࣗಈԽʹޭ! ͦΕʹΑΓҎԼ͕࣮ݱͨ͠ •
Swagger UIͰOpenAPI.jsonΛݩʹAPI༷ॻͷڞ༗ • openapi-request-validatorΛ༻͍ͨ APIͷres/reqόϦσʔγϣϯ
© Commune Inc. All rights reserved มॲཧͰ٧·ͬͨՕॴ • Class •
ϢχΦϯܕ • ॥ࢀরʹͳ͍ͬͯΔܕ • τϦοΩʔͳܕఆٛ ݸผʹରԠՄೳ͕ͩɺͦͷίʔυෳࡶʹͳ͍ͬͯ͘ɻɻɻ APIͷreq/resͷఆٛఆ͕ٛҎԼͷΑ͏ͳ߹
ࠓޙͷ՝
© Commune Inc. All rights reserved ࠓޙͷ՝ • Tsunaggerͷอक •
୯७ͳΦϒδΣΫτ ϓϦϛςΟϒͳܕఆٛͰͳ͍߹ͷରॲ • ผͷํ๏ͷݕ౼ ◦ APIܕఆٛΛzodͰߦ͍ɺzod-to-openapi ֎෦ϥΠϒϥϦͰOpenAPI.jsonΛ࡞ ◦ zodͷҠߦظؒதTsunaggerʹΑΔOpenAPI.jsonΛ ར༻͢Δ༧ఆ
·ͱΊ
© Commune Inc. All rights reserved • ϑϩϯτΤϯυͱόοΫΤϯυͰ APIͷܕఆٛϑΝΠϧΛڞ༗͍ͯ͠Δ ·ͱΊ
• ϞόΠϧͱͷ࿈ܞͷͨΊʹOpenAPI.json͕ඞཁʹͳͬͨ • Compiler APIΛར༻͠ɺ TSͷܕఆٛϑΝΠϧ͔ΒOpenAPI.json͕࡞Ͱ͖ͨ • ୯७Ͱͳ͍ܕఆٛͷมՄೳͰ͋Δ͕ίʔυ͕ෳࡶʹͳΔ
࠷ޙʹએͰ͢📢
© Commune Inc. All rights reserved 31 ίϛϡʔϯ͋ͳͨͷΩϟϦΞΛ࣮ݱ͢ΔϏʔΫϧͰ͢ʂ XΞΧϯτ @CommuneDev
ϑΥϩʔ͓ئ͍͠·͢! ΤϯδχΞ͚ձࣾใ https://commmune.notion.site/ver- 0b895a0187ef4954a2d5182afd82082d
32 © Commune Inc. All rights reserved