$30 off During Our Annual Pro Sale. View Details »

現実世界のJSON Hyper-Schema / Real World JSON Hyper-Schema

現実世界のJSON Hyper-Schema / Real World JSON Hyper-Schema

Ruby Business User Conference 2015での発表資料です。

Kenichi Takahashi

February 25, 2015
Tweet

More Decks by Kenichi Takahashi

Other Decks in Programming

Transcript

  1. GMO Pepabo, Inc. Kenichi TAKAHASHI 2015/02/25 Ruby Business User Conference

    2015 ݱ࣮ੈքͷ +40/)ZQFS4DIFNB
  2. ߴڮ݈Ұ!LFODIBO (.0ϖύϘגࣜձࣾ ٕज़෦ٕज़ج൫νʔϜ IUUQTIVDSFBNOFU

  3. None
  4. None
  5. ࠓ೔ͷ͓࿩  +40/)ZQFS4DIFNBͱ͸  ϖύϘͱ+40/)ZQFS4DIFNB  ͓·͚

  6. +40/ )ZQFS4DIFNB ͱ͸

  7. +40/4DIFNB  +40/ͷσʔλߏ଄Λఆٛ͢Δ  +40/4DIFNB$PSF  +40/4DIFNB7BMJEBUJPO  ࠷৽൛͸ESBGU

  8. +40/)ZQFS4DIFNB  +40/4DIFNBʹ+40/ΛϋΠύʔ ςΩετͱͯ͠ղऍͰ͖ΔΑ͏ʹ͢ ΔͨΊͷΩʔϫʔυΛ௥Ճͨ͠΋ͷ

  9. +40/)ZQFS4DIFNBͰग़དྷΔࣄ  +40/4DIFNBΛ࢖ͬͯ"1*ͷΤϯ υϙΠϯτΛఆٛ͢Δ  ϦΫΤετɺϨεϙϯεͷόϦσʔγϣϯ  υΩϡϝϯτੜ੒  ΫϥΠΞϯτੜ੒

     ςετ༻ελϒαʔόͷੜ੒
  10. αʔϏεσΟεΫϦϓγϣϯ  84%-  +40/)ZQFS4DIFNB  "1*#MVFQSJOU  3".-

  11. http://d.hatena.ne.jp/tkawa/20140828/p1

  12. ϖύϘͱ +40/ )ZQFS4DIFNB

  13.  ͭͷαʔϏεͰಋೖ४උத  Χϥʔϛʔγϣοϓ"1*  46;63* ϖύϘͱ+40/)ZQFS4DIFNB

  14. None
  15. ಋೖ͢Δૂ͍  "1*Λ࢖͏ਓ  ࣮૷ͱဃ཭͍ͯ͠ͳ͍υΩϡϝϯτ  ΫϥΠΞϯτϥΠϒϥϦͰ؆୯ʹར༻  ΧελϚʔαϙʔτͷෛ୲ܰݮ 

    ։ൃޮ཰ͷ޲্  ΤϯυϙΠϯτͷ࢓༷Λத৺ʹٞ࿦  ελϒͰ"1*։ൃ͕ϘτϧωοΫʹͳΒͳ͍
  16. None
  17. ಋೖεςοϓ  Ϩεϙϯε+40/ͷ4DIFNBΛॻ͘  +40/)ZQFS4DIFNBʹ͢Δ  ࣗಈͰόϦσʔγϣϯΛ͔͚ΔΑ͏ʹ͢Δ  υΩϡϝϯτੜ੒ʹඞཁͳ৘ใΛ௥ه͢Δ 

    υΩϡϝϯτΛੜ੒ɺެ։͢Δ  +40/)ZQFS4DIFNBΛެ։͢Δ  ΫϥΠΞϯτϥΠϒϥϦΛ഑෍͢Δ
  18. ಋೖεςοϓ  Ϩεϙϯε+40/ͷ4DIFNBΛॻ͘  +40/)ZQFS4DIFNBʹ͢Δ  ࣗಈͰόϦσʔγϣϯΛ͔͚ΔΑ͏ʹ͢Δ  υΩϡϝϯτੜ੒ʹඞཁͳ৘ใΛ௥ه͢Δ 

    υΩϡϝϯτΛੜ੒ɺެ։͢Δ  +40/)ZQFS4DIFNBΛެ։͢Δ  ΫϥΠΞϯτϥΠϒϥϦΛ഑෍͢Δ
  19. +40/4DIFNBΛॻ͘  Ϧιʔεຖʹ+40/4DIFNBΛ࡞Δ  \SFTPVSDF^JEKTPOΛϕʔεʹ  IUUQKTPOTDIFNBOFU  +40/UP+40/4DIFNB 

    ղऍ΍ग़ྗͷΦϓγϣϯ͕બ୒Ͱ͖Δ  FOVNɺSFRVJSFEɺBEEJUJPOBMQSPQFSUJFT FUD  Ϧετͷղऍͷڍಈ͸஫ҙ  45*΍ϙϦϞʔϑΟοΫؔ࿈Λ࢖͍ͬͯΔ৔߹ʹ໰୊ʹ
  20. ͏·͍͔͘ͳ͍ྫ { "payment_methods": [ { "category": "creadit_card", "gateway": "gmo-pg" },

    { "category": "bank", "name": "mizuho" } ] } { … "properties": { "payment_method": { "id": "payment_method", "type": "array", "items": { "id": "1", "type": "object", "properties": { "category": { "id": "category", "type": "string" }, "name": { "id": "name", "type": "string" } } } } } } HBUFXBZͱ͍͏ ϓϩύςΟ͕ͳ͔ͬͨ͜ͱʹ
  21. IUUQTHJUVCDPNLFODIBOTDIFNJ[F $ cat payments.json | bundle exec schemize --- schema:

    type: object properties: payment_method: type: array items: type: object properties: category: type: string gateway: type: string name: type: string
  22. IUUQTHJUVCDPNLFODIBOTDIFNJ[F  ඪ४ೖྗΛಡΉ  DVSMͰ࣮σʔλΛ؆୯ʹྲྀ͠ࠐΊΔ  Ϧετ಺ͷϓϩύςΟΛશͯྻڍ  ඍົͳߏ଄ɺ45*ɺϙϦϞʔϑΟοΫؔ࿈ʹରԠ 

    :".-ܗࣜͷग़ྗ  ޙड़͢Δπʔϧͷ΄ͱΜͲ͸:".-ΛಡΊΔ  +40/ΑΓ͸ਓ͕ؒฤू͠΍͍͢
  23. ಋೖεςοϓ  Ϩεϙϯε+40/ͷ4DIFNBΛॻ͘  +40/)ZQFS4DIFNBʹ͢Δ  ࣗಈͰόϦσʔγϣϯΛ͔͚ΔΑ͏ʹ͢Δ  υΩϡϝϯτੜ੒ʹඞཁͳ৘ใΛ௥ه͢Δ 

    υΩϡϝϯτΛੜ੒ɺެ։͢Δ  +40/)ZQFS4DIFNBΛެ։͢Δ  ΫϥΠΞϯτϥΠϒϥϦΛ഑෍͢Δ
  24. +40/)ZQFS4DIFNB  +40/4DIFNBʹ+40/ΛϋΠύʔ ςΩετͱͯ͠ղऍͰ͖ΔΑ͏ʹ͢ ΔͨΊͷΩʔϫʔυʮMJOLʯͳͲΛ ௥Ճͨ͠΋ͷ  $36% MJTUΛத৺ʹߟ͍͑ͯ͘

  25. +40/)ZQFS4DIFNB  MJOL৘ใ  EFTDSJQUJPO  SFM  ISFG 

    NFUIPE  UJUMF
  26. γϯϓϧͳMJOL schema: ! … ! links: - description: all payment

    methods href: /v1/payment_methods.json method: GET rel: instances title: payment_methods
  27. ෳࡶͳMJOL  ϨεϙϯεͷεΩʔϚ͕ݸผʹҧ͏  ϖʔδωʔγϣϯͷͨΊͷϝλσʔλ  ϦΫΤετͷόϦσʔγϣϯ  (&5ύϥϝʔλ 

    ϦΫΤετ#PEZ
  28. MJOLຖʹεΩʔϚΛఆٛ schema: ! … ! links: - description: all payment

    methods href: /v1/payment_methods.json method: GET rel: instances title: payment_methods targetSchema: type: object properties: payment_methods: type: array items: type: object $ref: "/schemata/payment_methods/#" meta: type: object properties: page: type: integer SFGͰผͷ৔ॴͰఆٛͨ͠ εΩʔϚΛಡΈࠐΉ UBSHFU4DIFNBͰϨεϙϯεͷ εΩʔϚΛࢦఆ͢Δ
  29. ಋೖεςοϓ  Ϩεϙϯε+40/ͷ4DIFNBΛॻ͘  +40/)ZQFS4DIFNBʹ͢Δ  ࣗಈͰόϦσʔγϣϯΛ͔͚ΔΑ͏ʹ͢Δ  υΩϡϝϯτੜ੒ʹඞཁͳ৘ใΛ௥ه͢Δ 

    υΩϡϝϯτΛੜ੒ɺެ։͢Δ  +40/)ZQFS4DIFNBΛެ։͢Δ  ΫϥΠΞϯτϥΠϒϥϦΛ഑෍͢Δ
  30. +40/4DIFNBͰόϦσʔγϣϯ  ର৅ͷ؀ڥ  UFTU EFWFMPQNFOU QSPEVDUJPO  όϦσʔγϣϯΤϥʔͷͱ͖ 

    αʔόΤϥʔɺϩάग़ྗ  ϦΫΤετͱϨεϙϯε
  31. ϥΠϒϥϦ  )FSPLVϓϩμΫτ  IUUQTHJUIVCDPNJOUFSBHFOU  SLBNVSBϓϩμΫτ  IUUQSLBNVSBIBUFOBCMPHDPN FOUSZ

     ͦͷଞ  IUUQTHJUIVCDPNTFPNP[JOUFSQPM
  32. )FSPLV  QSNE  +40/4DIFNB݁߹ɺυΩϡϝϯτੜ੒  DPNNJUUFF  όϦσʔγϣϯɺελϒαʔό 

    IFSPJDT  ΫϥΠΞϯτੜ੒
  33. SLBNVSB  +EPD  υΩϡϝϯτੜ੒  SBDLKTPO@TDIFNB  όϦσʔγϣϯɺελϒαʔόɺFUDʜ 

    +TPOJTN  ΫϥΠΞϯτੜ੒
  34. ͦͷଞ  TFPNP[JOUFSQPM  υΩϡϝϯτੜ੒  όϦσʔγϣϯ  ελϒαʔό

  35. ϖύϘͰ͸  Χϥʔϛʔγϣοϓ"1*  JOUFSQPMΛಋೖ͕ͨ͠ఫୀத  QSNE  SBDLKTPO@TDIFNBcDPNNJUUFF 

     46;63*  QSNE DPNNJUUFF
  36. *OUFSQPMΛࢼͯ͠Έͯ  ελϒαʔό͸ॊೈ  JOUFSQPM͸ελϒͰฦ͢+40/Λࣗ෼Ͱఆٛ  ଞ͸εΩʔϚ಺ͷFYBNQMFΛ࢖͏  +40/4DIFNBͷόʔδϣϯ͕ݹ͍ 

    JOUFSQPM͸ESBGUͰBOZ0GͳͲ͕࢖͑ͳ͍  ᐆດͳΤϯυϙΠϯτΛ۠ผͰ͖ͳ͍  VTFSTJEKTPOͱVTFSTTUBUTKTPO  ϑϧελοΫݫ͍͠
  37. ࠓ͔Β࢝ΊΔͳΒ  QSNE͔Β࢝ΊΔ  +40/4DIFNBͷ݁߹ʹ͸࢖͑Δ  ബ͍ϥΠϒϥϦΛ࢖͏  த৺͸+40/4DIFNB 

    ϥΠϒϥϦͷিಥʹ஫ҙ  KTPOTDIFNBͱKTPO@TDIFNB
  38. ςετͷ͓ڙʹ  LFODIBOSTQFDIUUQ@EFGBVMU@IFBEFS  SFRFVTUTQFDͰ)551ϔομΛ؆୯ʹ
 ෇͚Δ  "DDFQUBQQMJDBUJPOKTPO  "VUIPSJ[BUJPOZPVSPBVUIUPLFO

  39. STQFDIUUQ@EFGBVMU@IFBEFS

  40. +40/4DIFNBͰόϦσʔγϣϯ  ର৅ͷ؀ڥ  UFTUPSEFWFMPQNFOU  όϦσʔγϣϯΤϥʔͷͱ͖  αʔόΤϥʔ 

    ϦΫΤετͱϨεϙϯε  ·ͣ͸Ϩεϙϯε  ϦΫΤετ͸طଘͷόϦσʔγϣϯͰ
  41. ಋೖεςοϓ  Ϩεϙϯε+40/ͷ4DIFNBΛॻ͘  +40/)ZQFS4DIFNBʹ͢Δ  ࣗಈͰόϦσʔγϣϯΛ͔͚ΔΑ͏ʹ͢Δ  υΩϡϝϯτੜ੒ʹඞཁͳ৘ใΛ௥ه͢Δ 

    υΩϡϝϯτΛੜ੒ɺެ։͢Δ  +40/)ZQFS4DIFNBΛެ։͢Δ  ΫϥΠΞϯτϥΠϒϥϦΛ഑෍͢Δ
  42. πʔϧͷ࢖͑͹0,  )FSPLVϓϩμΫτ  IUUQTHJUIVCDPNJOUFSBHFOU  SLBNVSB͞ΜϓϩμΫτ  IUUQSLBNVSBIBUFOBCMPHDPN FOUSZ

     ͦͷଞ  IUUQTHJUIVCDPNTFPNP[JOUFSQPM
  43. ͓·͚

  44. ࠷ۙ΍͍ͬͯΔ͜ͱ  ര଎ϓϨΪϡʔϓϩΩγQPPMΛ࢖ͬͨ ΠϯςάϨʔγϣϯ؀ڥͷߏங  IUUQTHJUIVCDPNNPPLKQQPPM  QVMMܕͷϓϨϏϡʔ؀ڥ  ʮTUBHJOH࢖͍·͢ʯએݴ͔Βͷ୤٫

     ίϯςφ্Ͱಈ࡞ՄೳͳϙʔλϏϦςΟ ͷߴ͍ΞϓϦέʔγϣϯ΁
  45. QPPMΛར༻ͨ͠ϓϨϏϡʔ؀ڥ HJUQVMMͯ͠ ίϯςφΛཱͪ͋͛Δ OFXGFBUVSF ϒϥϯνΛQVTI OFXGFBUVSFDBSUʹ ΞΫηε͢Δ

  46. ·ͱΊ

  47. ࠓ೔ͷ͓࿩  +40/)ZQFS4DIFNBͱ͸  ϖύϘͰͷ+40/)ZQFS4DIFNB  ͓·͚

  48. ϖύϘͰ͸  伱ؒΛຒΊΔϥΠϒϥϦΛ࡞੒  Χϥʔϛʔγϣοϓ"1*  JOUFSQPMΛಋೖ͕ͨ͠ఫୀத  QSNE 

    SBDLKTPO@TDIFNBcDPNNJUUFF   46;63*  QSNE DPNNJUUFF
  49. QPPMΛར༻ͨ͠ϓϨϏϡʔ؀ڥ HJUQVMMͯ͠ ίϯςφΛཱͪ͋͛Δ OFXGFBUVSF ϒϥϯνΛQVTI OFXGFBUVSFDBSUʹ ΞΫηε͢Δ

  50. None