æè¿ã15幎ã®æŽå²ãæã€æ¯æããµãŒãã¹ã§ããYandex.Kassi APIãåèµ·åããŸããã ãã®ãããªéå¿çãªèª²é¡ã解決ããæ¹æ³ããäŒãããããšæããŸãã ãã®è³æã¯äžé£ã®èšäºã«ãŸãšããããŠãããããããã§ã¯ãAPIã®èšèšãåŠçãããã³ããŒã«ãšããã»ã¹ã«ã€ããŠè©³ãã説æããŸãã
ãŠãŒãã£ãªãã£ãè©äŸ¡ããããã®ããŒã¯ãŒãïŒ APIãRESTãOpenAPIãSwaggerãã·ã¹ãã çžäºäœçšã®ãªãã¡ã¯ã¿ãªã³ã° ã
åé¡æããŸãã¯ãã®äŒè©±ã¯äœã«ã€ããŠã§ãã
å°èŠæš¡ãªããŒã ãæ°èäŒæ¥ãã倧äŒæ¥ã«è»¢åãããšãããœãããŠã§ã¢ã³ã³ããŒãã³ããšãã®çžäºäœçšã«é¢ãããã¹ãŠã®ç¥èãå¿ã«çããããšã¯ã§ããŸããã ãããã£ãŠã2ã€ã®å°é£ããããŸãã
- éšéããšã«ç¬èªã®èšç»ããããåæã«äœæ¥ãè¡ãããšãåžžã«å¯èœã§ãããšã¯éããŸããã çžäºäœçšã®æé ã«åæãã海岞ã§ææžåããå¿ èŠããããŸãã
- ãµãŒãã¹æäœã®ã«ãŒã«ããã³ãããšã®çµ±åã«é¢ããåç §ç¥èãç¶æããããšãéèŠã§ãã åœäºè éã®çžäºäœçšã®é åºãä¿®æ£ããªãå Žåãããã¯ã¯ããã«å°é£ã§ãã
ã¹ã¯ã©ã ãªã©ã®éçºæ¹æ³è«ã«ããããããã®åé¡ãçæéã§é€å»ã§ããŸãã
- äžéšã®ã¿ã¹ã¯ã®è€éãã¯1ã€ã®ããŒã ã®ç¯å²ãè¶ ããŠãããäžç·ã«å¯ŸåŠããå¿ èŠããããŸãã
- 1ã€ã®è£œåã®ã¿ã«æ確ã«åž°å±ããããšã®ã§ããªãã¿ã¹ã¯ããããã·ã¹ãã ã®ããã€ãã®ã³ã³ããŒãã³ãã®èª¿æŽãããå€æŽãå¿ èŠã§ãã
- ã¡ã³ããã³ã¹ã¿ã¹ã¯ã«ã¯ãå€ããµãŒãã¹ã®æ¹è¯ãå¿ èŠã§ãã éåžžã«å€ãããããããã®ç¥èã¯ä»¥åã®æããã倱ããŸããã
10幎éãYandex.Moneyã®éçºè ã¯ãWikiããŒãžããXMLã¹ããŒããJSONã¹ããŒããOpenAPI / SwaggerãŸã§ã®çžäºäœçšãèšè¿°ããããšã§ãããã確信ããŠããŸããã
APIä»æ§èšèšããŒã«-æåã¯èšèã§ãã
ãã¹ãŠã¯ããªã¯ãšã¹ããšã¬ã¹ãã³ã¹ã®äŸãšãšãã«ãWikiãšMicrosoft Wordã§ã®ãµãŒãã¹ã®çžäºäœçšã®èª¬æããå§ãŸããŸããã ååãšããŠãããŒã¿è»¢éã«ã¯XMLã䜿çšãããŸããã ããã¯äœããªãããã¯ãŸãã§ãããããã®ãããªææžåã®æ¹æ³ã¯ã人ãã人ãžç¥èã移ãã®ã«é©ããŠããŸãã
ä»»æã®ããã¹ãèšè¿°ã¯ãç°ãªãéšéã®äººã ã«ãã£ãŠææ§ã«è§£éãããå¯èœæ§ããããããæŠå¿µãšçšèªã®çµ±äžãããã·ã¹ãã ãå¿ èŠã§ããã éçºè ã®æ°ãå¢ããã«ã€ããŠãçžäºäœçšã®èšè¿°ã®åœ¢åŒåãå¿ èŠã«ãªããŸããã
æäœãããŒã¿åãããã³ãããã®å¢çæ¡ä»¶ã®æ£åŒãªèª¬æã¯ãéçºã ãã§ãªãããŠããããã¹ãã®èªååã«ãå¿ èŠã§ãã æåã®æ£åŒãªAPIãµãŒãã¹ã³ã³ãã©ã¯ããXMLã¹ããŒã圢åŒã§èª¬æããåŸã§JSONã¹ããŒããè©ŠããŸããã ãã ããã©ã¡ããå®å šã§ã¯ãªããããWikiãŸãã¯Microsoft Wordã®ããã¹ãèšè¿°ããå®å šã«åãæ¿ããããšã¯å°é£ã§ãã
- XMLã¹ããŒãã§ã¯ãäœæ¥ã·ããªãªã説æããå®å šãªããã¥ã¡ã³ããè¿œå ããããšã¯äžå¯èœã§ãããåå¥ã«ä¿æããå¿ èŠããããŸãã
- JSONã¹ããŒã-ååãªã€ã³ã¹ãã«ã¡ã³ããµããŒãã®ãªãç²ãããä»æ§ã§ããå®å šãªããã¥ã¡ã³ããå«ããããšãã§ããŸããã
以åã¯SwaggerãšããŠç¥ãããŠããOpenAPIãçæ³çã§ããã OpenAPI Initiativeã¯ãLinux Foundationãéå¶ãããªãŒãã³ãœãŒã¹ãããžã§ã¯ãã§ãã 圌ã«ã¯çŽ æŽãããæªæ¥ãåŸ ã£ãŠãããšç¢ºä¿¡ããŠããŸãã
OpenAPI 3ã§ã¯ãããã¥ã¡ã³ããšå¯Ÿè©±åœ¢åŒã®èª¬æã1ã€ã®ä»æ§ãã¡ã€ã«ã«ãŸãšããããšãã§ããŸãã ããã¯éåžžã«éèŠãªå質ã§ããããã¹ãããã¥ã¡ã³ããšAPIä»æ§ãã¡ã€ã«ãåæããŠããªãããšã¯ãããŸããã
ç§ãã¡ã®ãããžã§ã¯ãã§ã¯ãYAML圢åŒã®OpenAPI 3ä»æ§ãã¡ã€ã«ã䜿çšããŠããŸãããã®çç±ã¯æ¬¡ã®ãšããã§ãã
- JSONãããYAMLã®æ¹ãèªã¿ãããã§ãã
- CommonMark圢åŒïŒä»¥åã®MarkdownïŒã®ããã¥ã¡ã³ããå«ãŸããŠããŸãã ãããã¯ããã©ãŒãããããªã¹ããããŒãã«ãåŒçšãã³ãŒãäŸã§ãã
- ããã¥ã¡ã³ãã¯ãç®çã®ä»æ§ãªããžã§ã¯ãã«è¿œå ãããåå¥ã®ã»ã¯ã·ã§ã³ã«èšè¿°ãããŠããŸããã
ãµãŒãã¹å解ããã³å€æŽç®¡ç
å€ãã®çµç¹ãçŽé¢ããäžè¬çãªåé¡ã¯ãããã¥ã¡ã³ãå€æŽç®¡çã§ãã 䞊è¡ããŠããããžã§ã¯ãããšã«å¥ã ã®å€æŽãå ããããå€ãã®ããã¥ã¡ã³ãããããŸãã å€ãã®ãããžã§ã¯ãã®ããã¥ã¡ã³ããç¶æããããšã¯éåžžã«é£ããããã人çºçãšã©ãŒã®å¯èœæ§ãé«ããªããŸãã
OpenAPIä»æ§ã¯YAML圢åŒã®ããã¹ããã¡ã€ã«ã§ããã€ãŸããã³ãŒããšåæ§ã«äœæ¥ã§ããŸãã
- ããŒãžã§ã³ç®¡çã·ã¹ãã ã䜿çšããŸãã
- ãã©ã³ããã¿ã°ããªãªãŒã¹ã«åºã¥ããŠå€æŽãæè»ã«ç®¡çããŸãã
- 䞊è¡ããŠãå€ãã®äººã ãå€ãã®ãããžã§ã¯ãã«å€æŽãå ããŸãã
- ã¬ãã¥ãŒæé ãäœæããã¡ã€ã³ææžãžã®å€æŽãåãå ¥ããŸãã
- ç¹å®ã®ãããžã§ã¯ãã®ã³ã³ããã¹ãã§ããã¥ã¡ã³ãã®ç¹å®ã®ããŒãžã§ã³ãåç §ããŸãã
ç§ãã¡ã®ãããžã§ã¯ãã¯ã WebããŒãžãã©ã°ã€ã³ãåããAtlassian BitbucketããŒãžã§ã³ç®¡çã·ã¹ãã ã䜿çšããŠããŸãã ããã«ãããã³ãŒããšåæ§ã«ä»æ§ãåæã«æäœããHTML圢åŒã§çµã¿ç«ãŠãããããã¥ã¡ã³ãã衚瀺ã§ããŸãã
äž»èŠãªã¿ã¹ã¯ãäžé£ã®ãµãŒãã¹ã«å解ããå Žåãæè¡ã³ãã¥ããã£ã§ã¯ãªããã¢ããªã±ãŒã·ã§ã³é åã®ãã¡ã€ã³ããšã«æ©èœãåå²ãããšããååã«äŸåããããšããå§ãããŸãã
åAPIãµãŒãã¹ã®èåŸã«ã¯ç¹å®ã®ããžãã¹ããã»ã¹ããããåAPIãµãŒãã¹ã¯åå¥ã®OpenAPIä»æ§ãã¡ã€ã«ã«ãã£ãŠèšè¿°ãããŸãã ãããŠã圌èªèº«ã®è£œåããŒã ããããæ åœããŠããŸãã ããã念é ã«çœ®ããŠãOpenAPIä»æ§ãã¡ã€ã«ã»ããã§ã¯ãåãã¡ã€ã«ã¯ãã®ã¢ããªã±ãŒã·ã§ã³è£œåã«å¯Ÿå¿ããŠããŸãã
ãããã£ãŠãæ®ãã¯æè¡çãªåé¡ã§ãããBitbucketã§é©åãªãªããžããªãäœæããåAPIãµãŒãã¹ãæ åœããã¬ãã¥ãŒã¢ã®ã°ã«ãŒããæ§æããããšã¯æ®ã£ãŠããŸãã ãã®çµæãBitbucketã«ã¯APIã®å ±éã«ã¿ãã°ã§ããAPIä»æ§ã®ãããžã§ã¯ãããããŸãã
ä»æ§ãã¡ã€ã«ã¯ã察象補åããšã«ã°ã«ãŒãåãããŠããŸãã
- åäžã®è£œåã®APIä»æ§ã¯ãåäžã®ãªããžããªã§ãã¹ããããŸãã
- ããŸããŸãªè£œåã®APIãããŸããŸãªãªããžããªã§ãã¹ããããŠããŸãã
ã€ãŸãã1ã€ã®ãªããžããªã1ã€ã®è£œåã«å¯Ÿå¿ããŸãã補åããžãã¹ããã»ã¹ãšãã®APIä»æ§ã®éçºãšä¿å®ã®ããã»ã¹ãæ åœããããŒã ã§ãã
å®äºããå€ãã®ãããžã§ã¯ãã®çµæã«ãããšãGitãªããžããªã®æ§é ã¯æ¬¡ã®ãšããã§ããã
- ãã¹ã¿ãŒãã©ã³ãã¯ãçŸåšã®ä»æ§ã®ç¶æ ãåæ ããŸããããã¯ãäºå®äžæŠéã·ã¹ãã ã«ããã䜿çšå¯èœã§ãã
- ãããã¿ã€ããã©ã³ãã¯ãäžé£ã®è£œå䜿çšã·ããªãªãäœæããããã®ã¢ãŠãã©ã€ã³ãã¶ã€ã³ã察象ãšããŠããŸãã å°æ¥çã«ã¯ããã®åŸã®æè¡ç解決çã®åºç€ã圢æããåææ§é ã®å顧ã«åœ¹ç«ã€å¯èœæ§ããããŸãã
- èšèšã¿ã¹ã¯ã¯æ©èœãã©ã³ãã§éçºãããŸãã 1ã€ã®æ©èœãã©ã³ãã¯ãAPIãå€æŽããããã®åäžã®ãããžã§ã¯ããŸãã¯ã¿ã¹ã¯ã§ãã
- ãããžã§ã¯ãã«ã¯ã Swagger-UIåæåèšå®ãå«ãindex.htmlãã¡ã€ã«ãå«ãŸããŠããŸãã WebããŒãžãã©ã°ã€ã³ã®ãããã§ãããã¥ã¡ã³ããHTMLãšããŠè¡šç€ºã§ããŸãã ãããã£ãŠããªããžããªã®åãã©ã³ãã¯ãªã³ã©ã€ã³ã§HTMLããã¥ã¡ã³ãã衚瀺ããå€éšã·ã¹ãã ããã³ããã¥ã¡ã³ãããåç §ã§ããŸãã
æ§é ã«å ããŠããªããžããªãæäœããããã®ã«ãŒã«ãéçºããå¿ èŠããããŸããã
- ãã¹ã¿ãŒãã©ã³ããšãããã¿ã€ããã©ã³ããžã®æžã蟌ã¿æš©éã¯ãããŸãã;çŽæ¥èšé²ã¯çŠæ¢ãããŠããŸãã ãã¹ãŠã®ä»æ§å€æŽã¯ãæ©èœãã©ã³ãããã®ãã«ãªã¯ãšã¹ããšããŠè¡ãããŸãã
- Pull-Requestããã®å€æŽãäž»èŠãªä»æ§ã«è©²åœããå Žåããã®Pull-Requestã¯ãå¿ èŠãªãã¹ãŠã®ã¬ãã¥ãŒæ åœè ããã³ä»»æã®æ°ã®ãªãã·ã§ã³ã®ã¬ãã¥ãŒæ åœè ããæ¿èªãåããå¿ èŠããããŸãã
- å±¥æŽãä»æ§ãå€æŽããã¿ã¹ã¯ã®å±¥æŽã§ãããã«ãªã¯ãšã¹ãã¯ãå€æŽã«ã€ããŠè°è«ããåæããã®ã«æé©ã§ãã
- Pull-Requestã®ååšã®ã©ã®æ®µéã§ãæ©èœãã©ã³ãã«å€æŽãå ããããšãã§ããŸãããæ°ããå€æŽã«ã¯ã¬ãã¥ãŒã¢ãšã®èª¿æŽãå¿ èŠã§ãã
- ãã¹ã¿ãŒãã©ã³ããžã®Pull-Requestã®ããŒãžã¯ãäœæ¥äžã®ãªãªãŒã¹ãæŠéæäœã«æå ¥ããããšãã«å®è¡ãããŸãã
ãããã®ååã®ãããã§ãä»æ§ãæäœããããã®äŸ¿å©ã§ééçã§äºæž¬å¯èœãªç°å¢ãåŸãããŸããã
åé¡ã«å¯Ÿããé«å質ã®ãœãªã¥ãŒã·ã§ã³ã®åºç€ãšããŠã®èšèšåªå ã¢ãããŒã
æ°ãããµãŒãã¹ãèšèšãããšãã RESTã®ååã«äŸåããŸããããããã«å®å šã«ã¯æºæ ããŸãã-ããšãã°ãããããµãŒãã¹ã®ã¢ãŒããã¯ãã£ãè€éã«ããããåžžèã«åããå Žåã
RESTã®äŸ¡å€ã¯ããã®ã¢ãããŒãã§ã¯ããµãŒãã¹ãäžé£ã®ãšã³ãã£ãã£ãšãããã®ã¢ã¯ã·ã§ã³ã«å解ããå¿ èŠãããããšã§ãã
RESTã¯ã ãã¡ã€ã³é§åèšèšã®äŸ¿å©ãªåæ ã§ãã ç§ã®æèŠã§ã¯ãRESTã¢ãŒããã¯ãã£ã®ãããã§ãRPCã¢ãããŒãã䜿çšããŠä»¥åã«è¡ã£ããã®ãšæ¯èŒãããšãé©çšãããã¿ã¹ã¯ã®ããã·ã³ãã«ã§é«å質ã®ãªããžã§ã¯ãã¢ãã«ãåŸãããŸãã
é«å質ã®è£œåãäœæããããã«ãéçºè ã¯ä»¥åã®ãããžã§ã¯ãã®çµéšã®ã³ã³ããã¹ãå€ã§ã¿ã¹ã¯ã®äž»é¡é åã泚ææ·±ãç 究ããå¿ èŠããããŸãã ãããã£ãŠããã¶ã€ã³ãã¡ãŒã¹ãã¯ãé©çšãããåé¡ã解決ããã¢ãããŒããšããŠã®å°äœã確ç«ããŠããŸãã 次ã®2ã€ã®æ®µéã«åããããšãã§ããŸãã
ç 究ã説æãããã³å¯Ÿè±¡åéã®ãšã³ãã£ãã£ãšããã»ã¹ã®åœ¢åŒåã
- ä»ã®ãµãŒãã¹ãšã®å¯èœãªæ¥ç¶ãèæ ®ã«å ¥ããŠãAPIãµãŒãã¹ã䜿çšããã·ããªãªã®åœ¢åŒåã å éšã®å°éçšèªã§ã¯ãªããã¡ã€ã³çšèªã䜿çšããŠãã ãã-ãã®æ¹æ³ã«ããããŠãŒã¶ãŒã«ãããµãŒãã¹ã®æäœã®èª€è§£ãé¿ããããšãã§ããŸãã
ãã®äœæ¥ã®çµæã¯ãAPIãµãŒãã¹ã®ä»æ§ã«ãªããŸãã
- ãã¡ã€ã³ãšã³ãã£ãã£ãšãã®å±æ§ã®ã»ãããå®çŸ©ããŸãã
- åãšã³ãã£ãã£ã®ã©ã€ããµã€ã¯ã«ãšäžé£ã®ç¶æ ãå®çŸ©ããŸãã
- åãšã³ãã£ãã£ãšèãããããšã©ãŒç¶æ³ã§äžé£ã®ã¢ã¯ã·ã§ã³ãå®çŸ©ããŸã
APIä»æ§ãæ¢åã®å®è£ ããçæãããå Žåãã³ãŒããã¡ãŒã¹ãã¢ãããŒãã¯ãå§ãããŸãããåžžã«ä»¥åã®ãããžã§ã¯ããããœãªã¥ãŒã·ã§ã³ãç¶æ¿ããåé¡ã解決ããŸããã é¶ãšåµã®ãã©ããã¯ã¹ã解決ããæ¢ç¥ã®æ¹æ³ã¯ãããŸãã-質ã®é«ãå®è£ ãäœæããã«ã¯ããŸã察象åéã調æ»ãããµãŒãã¹ãèšèšããå¿ èŠããããŸããåé¡ãšèšèšã®ç 究ãå®è¡ãããåã«å¿ èŠãªå®è£ ãäœæããããšã¯ã§ããŸããã
ã¢ã³ããã¿ãŒã³REST
ã RESTã¯æ°ããSOAPã§ã ããšããèšäºã«è§ŠçºãããŠã RESTã®èª€ã£ã䜿çšã®äŸã®ãããã¯ã«é¢ããå®çšçãªèæ ®äºé ãå ±æããããšæããŸãã
RESTã¯CRUDã ãã§ã¯ãããŸãã
ã¯ãŒã¯ã·ã§ããã§ååããã¹ãŠã®ããã»ã¹ãCreate-Read-Update-Deleteã¢ãã«ã«ããã¯ããããšåªåããŠããã®ã¯é©ãã¹ãããšã§ãã 人çã¯ããè€éã§è±ãã§ããããžãã¹ããã»ã¹ã¯å€ãã®æäœã§æ§æããããšã³ãã£ãã£ã¯å€ãã®ç¶æ ãšãããã®éã®é·ç§»ãæã€ããšãã§ããŸãã
RESTã®å€ãã®èšäºã§ã¯ãRoy Thomas Fieldingã®ç 究ã ã¢ãŒããã¯ãã£ãŒã¹ã¿ã€ã«ãšãããã¯ãŒã¯ããŒã¹ã®ãœãããŠã§ã¢ã¢ãŒããã¯ãã£ã®èšèš ããRESTãå®çŸ©ããããã®äž»èŠãªãœãŒã¹ãšããŠæããŠããŸãïŒãã®ããŒããŒã®5ç« ãš6ç« ãåç §ïŒã httpåè©GET-POST-PUT-DELETEã䜿çšããŠãããã«ãªãæäœãå®çŸ©ããå¯äžã®æ¹æ³ãšããŠäœ¿çšããããšããå§ãããŸãã
RESTã¯ããµãŒãã¹ãäžé£ã®ãªãœãŒã¹ãšãããã®æäœã«å解ããååã§ãã POSTãªã¯ãšã¹ãã®ã¿ã«åºã¥ããŠå¿ èŠãªæ©èœããã¹ãŠå®è£ ãããšããããRESTã«ãªããŸãã
HTTPã¹ããŒã¿ã¹ã®ããžãã¹ããžãã¯ãšã©ãŒãåæ ãã
HTTPãããã³ã«ã«ã¯ããªã¯ãšã¹ããšã¬ã¹ãã³ã¹ã§ããŒã¿ãé ä¿¡ããããã®ãã©ã³ã¹ããŒãæ©èœãããããšã«æ³šæããŠãã ããã ããžãã¹ããžãã¯ãšããŒã¿è»¢éã¬ã€ã€ãŒãæ··åšãããªãã§ãã ããã ãhttpãªã¯ãšã¹ãããšãããžãã¹ããã»ã¹ã¢ã¯ã·ã§ã³ãã®æŠå¿µãæ確ã«åé¢ããŸãã HTTPã¹ããŒã¿ã¹ã³ãŒãã¯ãHTTPãªã¯ãšã¹ãã®å®è¡ã¹ããŒã¿ã¹ãåæ ããããã®ãã®ã§ãããããžãã¹ããžãã¯ã¬ãã«ã®ã¿ã¹ã¯ã«ã¯äœ¿çšããªãã§ãã ããã
ãã ããå€ãã®å Žåãä»éããHTTPãããã³ã«ã䜿çšããŸããããã«ãããå¿ç圢åŒã«æ¬¡ã®ãããªçŸ©åã課ãããŸãã
- OAuth 2.0èªå¯ãã¬ãŒã ã¯ãŒã¯
- OAuth 2.0èªèšŒãã¬ãŒã ã¯ãŒã¯ïŒãã¢ã©ãŒããŒã¯ã³ã®äœ¿çš
HTTPã¹ããŒã¿ã¹ã䜿çšããããšãé©åãªå žåçãªç¶æ³ã次ã«ç€ºããŸãã
- 400ïŒç¡å¹ãªãªã¯ãšã¹ã圢åŒããªã¯ãšã¹ãåŒæ°åœ¢åŒã
- 401ïŒã¯ã©ã€ã¢ã³ãèªèšŒãªãã
- 403ïŒã¯ã©ã€ã¢ã³ãèªèšŒãäžååã§ãã
- 5xxïŒãªã¯ãšã¹ãããµãŒãã¹ããŸãã¯äžéã²ãŒããŠã§ã€ãå©çšã§ããªãæè¡çãªãšã©ãŒã
ããžãã¹ããžãã¯ã¬ãã«ã®é害ã¯ããã®HTTPèŠæ±ã«ãã£ãŠæäœãå®è¡ããããšã³ãã£ãã£ã®å±æ§ãšããŠåæ ãããå¿ èŠããããŸãã
ããšãã°ãæ¯æãã®æåŠã¯ãã¯ã©ã€ã¢ã³ãã®ã¢ã«ãŠã³ãã®è³éäžè¶³ãåå ã§ããå¯èœæ§ããããŸãã ãã®å Žåãæ¯æãã®ããã®ãã¹ãŠã®httpãªã¯ãšã¹ãã¯æ£åžžã«å®äºããŸãã ãã®ç¶æ³ã¯ããšã³ãã£ãã£ãæ¯æããã®ç¶æ ã®å±æ§ã®åœ¢åŒã«åæ ãããå¿ èŠããããŸãã
ããžãã¹ããžãã¯æäœã®ããã®PUT / PATCHã¯ãšãªã®äœ¿çš
PUTãªã¯ãšã¹ãã¯ããµãŒããŒäžã®ããã¥ã¡ã³ããåãã¿ã€ããšæ§é ã®æ°ããããã¥ã¡ã³ãã«çœ®ãæããããšãç®çãšããŠãããããããžãã¹ããžãã¯æäœã«åžžã«é©ããŠãããšã¯éããŸããã åããªãœãŒã¹ãžã®GETãªã¯ãšã¹ãã¯ãPUTãªã¯ãšã¹ãåŒæ°ãè¿ãå¿ èŠããããŸãã
æšæºã§ã¯ãPUTèŠæ±ã次ã®ããã«å®çŸ©ããŠããŸãã
PUTã¡ãœããã¯ãã¿ãŒã²ãããªãœãŒã¹ã®ç¶æ ãäœæããããèŠæ±ã¡ãã»ãŒãžãã€ããŒãã«å«ãŸããè¡šçŸã§å®çŸ©ãããç¶æ ã«çœ®ãæããããšãèŠæ±ããŸãã
RFC 7231ç§4.3.4
PUTèŠæ±ã®æ£ããã¢ããªã±ãŒã·ã§ã³ã®äŸã¯ã Yandex.Diskã«ãã¡ã€ã«ãã¢ããããŒãããããšã§ã ã
RFC 5789 PATCHãªã¯ãšã¹ãã®é©çšæ§ãå¶éãããŠããŸãããã®ã»ãã³ãã£ã¯ã¹ã¯PUTã«äŒŒãŠããããªã¯ãšã¹ãã®æ¬æã¯RFC 6902 JSONãããããã¥ã¡ã³ãã§ãããããã¥ã¡ã³ãã§ã¯ãããŸããã
JSONãããããã¥ã¡ã³ãã®äŸïŒ
[ { "op": "remove", "path": "/a/b/c" }, { "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] }, { "op": "replace", "path": "/a/b/c", "value": 42 }, { "op": "move", "from": "/a/b/c", "path": "/a/b/d" } ]
ãã®æ§æã䜿çšããŠããžãã¹ããžãã¯æäœãã·ã³ãã«ã§ã¢ã¯ã»ã¹å¯èœãªæ¹æ³ã§èšè¿°ããããšã¯å®¹æã§ã¯ãªãããšã«åæããŸãã
ãããã£ãŠãã¿ã¹ã¯ãäžèšã®èŠä»¶ãæºãããŠããå Žåã¯PUT / PATCHã䜿çšããããã§ãªãå Žåã¯POSTã䜿çšããããšããå§ãããŸãã
çµè«ã«ããã€ãã®èšè
ITã·ã¹ãã ã¯åžžã«é²åããããè€éã«ãªã£ãŠããŸãã ããããä»æ¥ã®äž»ãªèª²é¡ã¯ãã·ã¹ãã ã®è€éãã®å¢å€§ãå¶éããããšã§ãã ç§ã®æèŠã§ã¯ãã·ã¹ãã ã®é©åãªå解ãšå€æŽç®¡çã®æ¹æ³ã¯ãç§ãã¡ã®ããŒãã¯ãŒã¯ã®è¯ãå©ãã§ãã
æ瀺ãããè³æãã圹ã«ç«ãŠã°å¹žãã§ãã JavaJamã§ã®RESTã®ãããªAPIã®èšèšã«é¢ããç§ã®ã¬ããŒããåç §ããŠãã ããã ãã¡ãã¯æçš¿ãžã®ãªã³ã¯ã§ãã