Upgrade to Pro — share decks privately, control downloads, hide ads and more …

現実世界の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

    View full-size slide

  2. ߴڮ݈Ұ!LFODIBO
    (.0ϖύϘגࣜձࣾ
    ٕज़෦ٕज़ج൫νʔϜ
    IUUQTIVDSFBNOFU

    View full-size slide

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

    View full-size slide

  4. +40/
    )ZQFS4DIFNB
    ͱ͸

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  8. αʔϏεσΟεΫϦϓγϣϯ
    84%-
    +40/)ZQFS4DIFNB
    "1*#MVFQSJOU
    3".-

    View full-size slide

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

    View full-size slide

  10. ϖύϘͱ
    +40/
    )ZQFS4DIFNB

    View full-size slide

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

    View full-size slide

  12. ಋೖ͢Δૂ͍
    "1*Λ࢖͏ਓ
    ࣮૷ͱဃ཭͍ͯ͠ͳ͍υΩϡϝϯτ
    ΫϥΠΞϯτϥΠϒϥϦͰ؆୯ʹར༻
    ΧελϚʔαϙʔτͷෛ୲ܰݮ
    ։ൃޮ཰ͷ޲্
    ΤϯυϙΠϯτͷ࢓༷Λத৺ʹٞ࿦
    ελϒͰ"1*։ൃ͕ϘτϧωοΫʹͳΒͳ͍

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. +40/4DIFNBΛॻ͘
    Ϧιʔεຖʹ+40/4DIFNBΛ࡞Δ
    \SFTPVSDF^JEKTPOΛϕʔεʹ
    IUUQKTPOTDIFNBOFU
    +40/UP+40/4DIFNB
    ղऍ΍ग़ྗͷΦϓγϣϯ͕બ୒Ͱ͖Δ
    FOVNɺSFRVJSFEɺBEEJUJPOBMQSPQFSUJFT FUD
    Ϧετͷղऍͷڍಈ͸஫ҙ
    45*΍ϙϦϞʔϑΟοΫؔ࿈Λ࢖͍ͬͯΔ৔߹ʹ໰୊ʹ

    View full-size slide

  16. ͏·͍͔͘ͳ͍ྫ
    {
    "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ͱ͍͏
    ϓϩύςΟ͕ͳ͔ͬͨ͜ͱʹ

    View full-size slide

  17. 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

    View full-size slide

  18. IUUQTHJUVCDPNLFODIBOTDIFNJ[F
    ඪ४ೖྗΛಡΉ
    DVSMͰ࣮σʔλΛ؆୯ʹྲྀ͠ࠐΊΔ
    Ϧετ಺ͷϓϩύςΟΛશͯྻڍ
    ඍົͳߏ଄ɺ45*ɺϙϦϞʔϑΟοΫؔ࿈ʹରԠ
    :".-ܗࣜͷग़ྗ
    ޙड़͢Δπʔϧͷ΄ͱΜͲ͸:".-ΛಡΊΔ
    +40/ΑΓ͸ਓ͕ؒฤू͠΍͍͢

    View full-size slide

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

    View full-size slide

  20. +40/)ZQFS4DIFNB
    +40/4DIFNBʹ+40/ΛϋΠύʔ
    ςΩετͱͯ͠ղऍͰ͖ΔΑ͏ʹ͢
    ΔͨΊͷΩʔϫʔυʮMJOLʯͳͲΛ
    ௥Ճͨ͠΋ͷ
    $36%MJTUΛத৺ʹߟ͍͑ͯ͘

    View full-size slide

  21. +40/)ZQFS4DIFNB
    MJOL৘ใ
    EFTDSJQUJPO
    SFM
    ISFG
    NFUIPE
    UJUMF

    View full-size slide

  22. γϯϓϧͳMJOL
    schema:
    !

    !
    links:
    - description: all payment methods
    href: /v1/payment_methods.json
    method: GET
    rel: instances
    title: payment_methods

    View full-size slide

  23. ෳࡶͳMJOL
    ϨεϙϯεͷεΩʔϚ͕ݸผʹҧ͏
    ϖʔδωʔγϣϯͷͨΊͷϝλσʔλ
    ϦΫΤετͷόϦσʔγϣϯ
    (&5ύϥϝʔλ
    ϦΫΤετ#PEZ

    View full-size slide

  24. 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ͰϨεϙϯεͷ
    εΩʔϚΛࢦఆ͢Δ

    View full-size slide

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

    View full-size slide

  26. +40/4DIFNBͰόϦσʔγϣϯ
    ର৅ͷ؀ڥ
    UFTU EFWFMPQNFOU QSPEVDUJPO
    όϦσʔγϣϯΤϥʔͷͱ͖
    αʔόΤϥʔɺϩάग़ྗ
    ϦΫΤετͱϨεϙϯε

    View full-size slide

  27. ϥΠϒϥϦ
    )FSPLVϓϩμΫτ
    IUUQTHJUIVCDPNJOUFSBHFOU
    SLBNVSBϓϩμΫτ
    IUUQSLBNVSBIBUFOBCMPHDPN
    FOUSZ
    ͦͷଞ
    IUUQTHJUIVCDPNTFPNP[JOUFSQPM

    View full-size slide

  28. )FSPLV
    QSNE
    +40/4DIFNB݁߹ɺυΩϡϝϯτੜ੒
    DPNNJUUFF
    όϦσʔγϣϯɺελϒαʔό
    IFSPJDT
    ΫϥΠΞϯτੜ੒

    View full-size slide

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

    View full-size slide

  30. ͦͷଞ
    TFPNP[JOUFSQPM
    υΩϡϝϯτੜ੒
    όϦσʔγϣϯ
    ελϒαʔό

    View full-size slide

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

    46;63*
    QSNEDPNNJUUFF

    View full-size slide

  32. *OUFSQPMΛࢼͯ͠Έͯ
    ελϒαʔό͸ॊೈ
    JOUFSQPM͸ελϒͰฦ͢+40/Λࣗ෼Ͱఆٛ
    ଞ͸εΩʔϚ಺ͷFYBNQMFΛ࢖͏
    +40/4DIFNBͷόʔδϣϯ͕ݹ͍
    JOUFSQPM͸ESBGUͰBOZ0GͳͲ͕࢖͑ͳ͍
    ᐆດͳΤϯυϙΠϯτΛ۠ผͰ͖ͳ͍
    VTFSTJEKTPOͱVTFSTTUBUTKTPO
    ϑϧελοΫݫ͍͠

    View full-size slide

  33. ࠓ͔Β࢝ΊΔͳΒ
    QSNE͔Β࢝ΊΔ
    +40/4DIFNBͷ݁߹ʹ͸࢖͑Δ
    ബ͍ϥΠϒϥϦΛ࢖͏
    த৺͸+40/4DIFNB
    ϥΠϒϥϦͷিಥʹ஫ҙ
    KTPOTDIFNBͱKTPO@TDIFNB

    View full-size slide

  34. ςετͷ͓ڙʹ
    LFODIBOSTQFDIUUQ@EFGBVMU@IFBEFS
    SFRFVTUTQFDͰ)551ϔομΛ؆୯ʹ

    ෇͚Δ
    "DDFQUBQQMJDBUJPOKTPO
    "VUIPSJ[BUJPOZPVSPBVUIUPLFO

    View full-size slide

  35. STQFDIUUQ@EFGBVMU@IFBEFS

    View full-size slide

  36. +40/4DIFNBͰόϦσʔγϣϯ
    ର৅ͷ؀ڥ
    UFTUPSEFWFMPQNFOU
    όϦσʔγϣϯΤϥʔͷͱ͖
    αʔόΤϥʔ
    ϦΫΤετͱϨεϙϯε
    ·ͣ͸Ϩεϙϯε
    ϦΫΤετ͸طଘͷόϦσʔγϣϯͰ

    View full-size slide

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

    View full-size slide

  38. πʔϧͷ࢖͑͹0,
    )FSPLVϓϩμΫτ
    IUUQTHJUIVCDPNJOUFSBHFOU
    SLBNVSB͞ΜϓϩμΫτ
    IUUQSLBNVSBIBUFOBCMPHDPN
    FOUSZ
    ͦͷଞ
    IUUQTHJUIVCDPNTFPNP[JOUFSQPM

    View full-size slide

  39. ࠷ۙ΍͍ͬͯΔ͜ͱ
    ര଎ϓϨΪϡʔϓϩΩγQPPMΛ࢖ͬͨ
    ΠϯςάϨʔγϣϯ؀ڥͷߏங
    IUUQTHJUIVCDPNNPPLKQQPPM
    QVMMܕͷϓϨϏϡʔ؀ڥ
    ʮTUBHJOH࢖͍·͢ʯએݴ͔Βͷ୤٫
    ίϯςφ্Ͱಈ࡞ՄೳͳϙʔλϏϦςΟ
    ͷߴ͍ΞϓϦέʔγϣϯ΁

    View full-size slide

  40. QPPMΛར༻ͨ͠ϓϨϏϡʔ؀ڥ
    HJUQVMMͯ͠
    ίϯςφΛཱͪ͋͛Δ
    OFXGFBUVSF
    ϒϥϯνΛQVTI
    OFXGFBUVSFDBSUʹ
    ΞΫηε͢Δ

    View full-size slide

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

    View full-size slide

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

    46;63*
    QSNEDPNNJUUFF

    View full-size slide

  43. QPPMΛར༻ͨ͠ϓϨϏϡʔ؀ڥ
    HJUQVMMͯ͠
    ίϯςφΛཱͪ͋͛Δ
    OFXGFBUVSF
    ϒϥϯνΛQVTI
    OFXGFBUVSFDBSUʹ
    ΞΫηε͢Δ

    View full-size slide